-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Description
Consider the below unit test:
[CompilerTrait(CompilerFeature.IOperation)]
[Fact]
public void NameOfExpressionWithTypeName()
{
string source = @"
class Class1
{
public string M()
{
return /*<bind>*/nameof(Class1)/*</bind>*/;
}
}
";
string expectedOperationTree = @"
INameOfOperation (OperationKind.NameOf, Type: System.String, Constant: """"Class1"""") (Syntax: 'nameof(Class1)')
IOperation: (OperationKind.None, Type: null) (Syntax: 'Class1')";
var expectedDiagnostics = DiagnosticDescription.None;
VerifyOperationTreeAndDiagnosticsForTest<InvocationExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics);
}The above unit test demonstrates that the tree has a none operation, which is normally reserved for not yet implemented operations for new language features.
This leads to bunch of our analyzers to bail out on all code with such name of expressions, for example all flow based analyzers, analyzers that flag symbols without read/write references (such as unused parameter/local/private field, etc.), which conservatively bail out on all method bodies with any OperationKind.None within the operation tree. Ideally, we should not have OperationKind.None for such a common code construct.
tompazourek