File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
ExternalProjects/BizHawk.Analyzer Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ namespace BizHawk . Analyzers ;
2+
3+ using System . Collections . Immutable ;
4+
5+ [ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
6+ public sealed class BrokenCollectionExpressionAnalyzer : DiagnosticAnalyzer
7+ {
8+ private static readonly DiagnosticDescriptor DiagBrokenCollectionExpression = new (
9+ id : "BHI1234" ,
10+ title : "don't this" ,
11+ messageFormat : "don't this" ,
12+ category : "Usage" ,
13+ defaultSeverity : DiagnosticSeverity . Warning ,
14+ isEnabledByDefault : true ) ;
15+
16+ public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; }
17+ = ImmutableArray . Create ( /*HawkSourceAnalyzer.DiagWTF,*/ DiagBrokenCollectionExpression ) ;
18+
19+ public override void Initialize ( AnalysisContext context )
20+ {
21+ context . ConfigureGeneratedCodeAnalysis ( GeneratedCodeAnalysisFlags . None ) ;
22+ context . EnableConcurrentExecution ( ) ;
23+ context . RegisterCompilationStartAction ( initContext =>
24+ {
25+ var arraySegmentSym = initContext . Compilation . GetTypeByMetadataName ( "System.ArraySegment`1" ) ! ;
26+ initContext . RegisterOperationAction (
27+ oac =>
28+ {
29+ var operation = ( ICollectionExpressionOperation ) oac . Operation ;
30+ if ( arraySegmentSym . Matches ( operation . Type ) ) DiagBrokenCollectionExpression . ReportAt ( operation , oac ) ;
31+ } ,
32+ OperationKind . CollectionExpression ) ;
33+ } ) ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments