@@ -50,6 +50,14 @@ public override void Initialize(AnalysisContext context)
5050 context . EnableConcurrentExecution ( ) ;
5151
5252 context . RegisterCompilationStartAction ( CompilationStartAction ) ;
53+ }
54+
55+ private static void HandleCompilationStart ( CompilationStartAnalysisContext context )
56+ {
57+ if ( ! context . SupportsTuples ( ) )
58+ {
59+ return ;
60+ }
5361
5462 context . RegisterSyntaxNodeAction ( MethodDeclarationAction , SyntaxKind . MethodDeclaration ) ;
5563 context . RegisterSyntaxNodeAction ( ConversionOperatorAction , SyntaxKind . ConversionOperatorDeclaration ) ;
@@ -59,10 +67,7 @@ public override void Initialize(AnalysisContext context)
5967
6068 context . RegisterSyntaxNodeAction ( DelegateDeclarationAction , SyntaxKind . DelegateDeclaration ) ;
6169 context . RegisterSyntaxNodeAction ( LambdaExpressionAction , SyntaxKinds . LambdaExpression ) ;
62- }
6370
64- private static void HandleCompilationStart ( CompilationStartAnalysisContext context )
65- {
6671 var expressionType = context . Compilation . GetTypeByMetadataName ( "System.Linq.Expressions.Expression`1" ) ;
6772
6873 context . RegisterSyntaxNodeAction ( context => HandleObjectCreationExpression ( context , expressionType ) , SyntaxKind . ObjectCreationExpression ) ;
@@ -75,11 +80,6 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte
7580
7681 private static void HandleMethodDeclaration ( SyntaxNodeAnalysisContext context )
7782 {
78- if ( ! context . SupportsTuples ( ) )
79- {
80- return ;
81- }
82-
8383 var methodDeclaration = ( MethodDeclarationSyntax ) context . Node ;
8484
8585 CheckType ( context , expressionType : null , methodDeclaration . ReturnType ) ;
@@ -88,11 +88,6 @@ private static void HandleMethodDeclaration(SyntaxNodeAnalysisContext context)
8888
8989 private static void HandleConversionOperator ( SyntaxNodeAnalysisContext context )
9090 {
91- if ( ! context . SupportsTuples ( ) )
92- {
93- return ;
94- }
95-
9691 var conversionOperatorDeclaration = ( ConversionOperatorDeclarationSyntax ) context . Node ;
9792
9893 CheckType ( context , expressionType : null , conversionOperatorDeclaration . Type ) ;
@@ -101,33 +96,18 @@ private static void HandleConversionOperator(SyntaxNodeAnalysisContext context)
10196
10297 private static void HandleBasePropertyDeclaration ( SyntaxNodeAnalysisContext context )
10398 {
104- if ( ! context . SupportsTuples ( ) )
105- {
106- return ;
107- }
108-
10999 var propertyDeclaration = ( BasePropertyDeclarationSyntax ) context . Node ;
110100 CheckType ( context , expressionType : null , propertyDeclaration . Type ) ;
111101 }
112102
113103 private static void HandleFieldDeclaration ( SyntaxNodeAnalysisContext context )
114104 {
115- if ( ! context . SupportsTuples ( ) )
116- {
117- return ;
118- }
119-
120105 var fieldDeclaration = ( BaseFieldDeclarationSyntax ) context . Node ;
121106 CheckType ( context , expressionType : null , fieldDeclaration . Declaration . Type ) ;
122107 }
123108
124109 private static void HandleLambdaExpression ( SyntaxNodeAnalysisContext context )
125110 {
126- if ( ! context . SupportsTuples ( ) )
127- {
128- return ;
129- }
130-
131111 var lambdaExpression = ( LambdaExpressionSyntax ) context . Node ;
132112 if ( lambdaExpression is ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpression )
133113 {
@@ -137,22 +117,12 @@ private static void HandleLambdaExpression(SyntaxNodeAnalysisContext context)
137117
138118 private static void HandleObjectCreationExpression ( SyntaxNodeAnalysisContext context , INamedTypeSymbol expressionType )
139119 {
140- if ( ! context . SupportsTuples ( ) )
141- {
142- return ;
143- }
144-
145120 var objectCreationExpression = ( ObjectCreationExpressionSyntax ) context . Node ;
146121 CheckType ( context , expressionType , objectCreationExpression . Type , objectCreationExpression . GetLocation ( ) ) ;
147122 }
148123
149124 private static void HandleInvocationExpression ( SyntaxNodeAnalysisContext context , INamedTypeSymbol expressionType )
150125 {
151- if ( ! context . SupportsTuples ( ) )
152- {
153- return ;
154- }
155-
156126 var invocationExpression = ( InvocationExpressionSyntax ) context . Node ;
157127 if ( invocationExpression . ArgumentList . Arguments . Count < 2 )
158128 {
@@ -181,34 +151,19 @@ private static void HandleInvocationExpression(SyntaxNodeAnalysisContext context
181151
182152 private static void HandleDefaultExpression ( SyntaxNodeAnalysisContext context , INamedTypeSymbol expressionType )
183153 {
184- if ( ! context . SupportsTuples ( ) )
185- {
186- return ;
187- }
188-
189154 var defaultExpression = ( DefaultExpressionSyntax ) context . Node ;
190155 CheckType ( context , expressionType , defaultExpression . Type ) ;
191156 }
192157
193158 private static void HandleDelegateDeclaration ( SyntaxNodeAnalysisContext context )
194159 {
195- if ( ! context . SupportsTuples ( ) )
196- {
197- return ;
198- }
199-
200160 var delegateDeclaration = ( DelegateDeclarationSyntax ) context . Node ;
201161 CheckType ( context , expressionType : null , delegateDeclaration . ReturnType ) ;
202162 CheckParameterList ( context , delegateDeclaration . ParameterList ) ;
203163 }
204164
205165 private static void HandleCastExpression ( SyntaxNodeAnalysisContext context , INamedTypeSymbol expressionType )
206166 {
207- if ( ! context . SupportsTuples ( ) )
208- {
209- return ;
210- }
211-
212167 var castExpression = ( CastExpressionSyntax ) context . Node ;
213168 CheckType ( context , expressionType , castExpression . Type ) ;
214169 }
0 commit comments