Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ private static void Analyze(SymbolAnalysisContext context)
if (member.IsAbstract || member.IsVirtual)
continue;

// skip properties
if (member is IMethodSymbol method && (method.MethodKind == MethodKind.PropertyGet || method.MethodKind == MethodKind.PropertySet))
// The accessors are reported through the property or event they belong to
if (member is IMethodSymbol { MethodKind: MethodKind.PropertyGet or MethodKind.PropertySet or MethodKind.EventAdd or MethodKind.EventRemove })
continue;

// skip operators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,38 @@ public class Test<T>
return test.RunAsync();
}

[Fact]
public Task StaticMembers_Event()
{
var test = CreateTest();
test.TestCode = """
public class Test<T>
{
public static event System.EventHandler {|MA0018:MyEvent|};
}
""";

return test.RunAsync();
}

[Fact]
public Task StaticMembers_EventWithExplicitAccessors()
{
var test = CreateTest();
test.TestCode = """
public class Test<T>
{
public static event System.EventHandler {|MA0018:MyEvent|}
{
add => throw null;
remove => throw null;
}
}
""";

return test.RunAsync();
}

[Fact]
public Task StaticMembers_Operator()
{
Expand Down