File tree Expand file tree Collapse file tree 3 files changed +38
-3
lines changed
ExternalProjects/BizHawk.Analyzer Expand file tree Collapse file tree 3 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 1212 <PackageVersion Include =" Meziantou.Polyfill" Version =" 1.0.50" />
1313 <PackageVersion Include =" Microsoft.Bcl.HashCode" Version =" 6.0.0" />
1414 <PackageVersion Include =" Microsoft.CodeAnalysis.BannedApiAnalyzers" Version =" 3.3.4" />
15- <PackageVersion Include =" Microsoft.CodeAnalysis.CSharp" Version =" 4.8 .0" />
16- <PackageVersion Include =" Microsoft.CodeAnalysis.CSharp.Workspaces" Version =" 4.8 .0" />
15+ <PackageVersion Include =" Microsoft.CodeAnalysis.CSharp" Version =" 4.14 .0" />
16+ <PackageVersion Include =" Microsoft.CodeAnalysis.CSharp.Workspaces" Version =" 4.14 .0" />
1717 <PackageVersion Include =" Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version =" 1.1.2" />
1818 <PackageVersion Include =" Microsoft.CSharp" Version =" 4.7.0" />
1919 <PackageVersion Include =" Microsoft.Data.Sqlite.Core" Version =" 8.0.4" />
3434 <PackageVersion Include =" Silk.NET.WGL.Extensions.NV" Version =" 2.21.0" />
3535 <PackageVersion Include =" SQLitePCLRaw.provider.e_sqlite3" Version =" 2.1.8" />
3636 <PackageVersion Include =" StyleCop.Analyzers" Version =" 1.2.0-beta.556" /><!-- don't forget to update .stylecop.json at the same time -->
37- <PackageVersion Include =" System.Collections.Immutable" Version =" 8 .0.0" />
37+ <PackageVersion Include =" System.Collections.Immutable" Version =" 9 .0.0" />
3838 <PackageVersion Include =" System.CommandLine" Version =" 2.0.0-beta4.22272.1" />
3939 <PackageVersion Include =" System.ComponentModel.Annotations" Version =" 5.0.0" />
4040 <PackageVersion Include =" System.Drawing.Common" Version =" 6.0.0" />
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 . OriginalDefinition ) ) DiagBrokenCollectionExpression . ReportAt ( operation , oac ) ;
31+ } ,
32+ OperationKind . CollectionExpression ) ;
33+ } ) ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments