11#nullable disable
22
3- using System . Linq ;
43using Microsoft . CodeAnalysis ;
54using static D2L . CodeStyle . Analyzers . Immutability . ImmutableDefinitionChecker ;
65
@@ -15,17 +14,11 @@ out Location location
1514 ) {
1615
1716 // Collect audit information
18- var hasStaticAudited = annotationsContext . Statics . Audited . IsDefined ( symbol ) ;
19- var hasStaticUnaudited = annotationsContext . Statics . Unaudited . IsDefined ( symbol ) ;
20- var hasMutabilityAudited = annotationsContext . Mutability . Audited . IsDefined ( symbol ) ;
21- var hasMutabilityUnaudited = annotationsContext . Mutability . Unaudited . IsDefined ( symbol ) ;
22- var hasBothStaticsAttributes = hasStaticAudited && hasStaticUnaudited ;
23- var hasBothMutabilityAttributes = hasMutabilityAudited && hasMutabilityUnaudited ;
24- var hasEitherStaticsAttributes = hasStaticAudited || hasStaticUnaudited ;
25- var hasEitherMutabilityAttributes = hasMutabilityAudited || hasMutabilityUnaudited ;
17+ var hasStaticAudited = annotationsContext . Statics_Audited . IsDefined ( symbol ) ;
18+ var hasMutabilityAudited = annotationsContext . Mutability_Audited . IsDefined ( symbol ) ;
2619
2720 // If there are no audits, don't do anything
28- if ( ! hasEitherStaticsAttributes && ! hasEitherMutabilityAttributes ) {
21+ if ( ! hasStaticAudited && ! hasMutabilityAudited ) {
2922 location = null ;
3023 return false ;
3124 }
@@ -36,33 +29,11 @@ out Location location
3629 . GetLastToken ( )
3730 . GetLocation ( ) ;
3831
39- // Check if both static audits are applied
40- if ( hasBothStaticsAttributes ) {
41- var diagnostic = Diagnostic . Create (
42- Diagnostics . ConflictingImmutability ,
43- syntaxLocation ,
44- "Statics.Audited" ,
45- "Statics.Unaudited" ,
46- symbol . Kind . ToString ( ) . ToLower ( ) ) ;
47- diagnosticSink ( diagnostic ) ;
48- }
49-
50- // Check if both mutability audits are applied
51- if ( hasBothMutabilityAttributes ) {
52- var diagnostic = Diagnostic . Create (
53- Diagnostics . ConflictingImmutability ,
54- syntaxLocation ,
55- "Mutability.Audited" ,
56- "Mutability.Unaudited" ,
57- symbol . Kind . ToString ( ) . ToLower ( ) ) ;
58- diagnosticSink ( diagnostic ) ;
59- }
60-
6132 AttributeData attr = null ;
6233
6334 if ( symbol . IsStatic ) {
6435 // Check if a static member is using mutability audits
65- if ( hasEitherMutabilityAttributes ) {
36+ if ( hasMutabilityAudited ) {
6637 var diagnostic = Diagnostic . Create (
6738 Diagnostics . InvalidAuditType ,
6839 syntaxLocation ,
@@ -72,11 +43,10 @@ out Location location
7243 diagnosticSink ( diagnostic ) ;
7344 }
7445
75- attr = annotationsContext . Statics . Audited . GetAll ( symbol ) . FirstOrDefault ( )
76- ?? annotationsContext . Statics . Unaudited . GetAll ( symbol ) . FirstOrDefault ( ) ;
46+ attr = annotationsContext . Statics_Audited . GetAll ( symbol ) . FirstOrDefault ( ) ;
7747 } else {
7848 // Check if a non-static member is using static audits
79- if ( hasEitherStaticsAttributes ) {
49+ if ( hasStaticAudited ) {
8050 var diagnostic = Diagnostic . Create (
8151 Diagnostics . InvalidAuditType ,
8252 syntaxLocation ,
@@ -86,8 +56,7 @@ out Location location
8656 diagnosticSink ( diagnostic ) ;
8757 }
8858
89- attr = annotationsContext . Mutability . Audited . GetAll ( symbol ) . FirstOrDefault ( )
90- ?? annotationsContext . Mutability . Unaudited . GetAll ( symbol ) . FirstOrDefault ( ) ;
59+ attr = annotationsContext . Mutability_Audited . GetAll ( symbol ) . FirstOrDefault ( ) ;
9160 }
9261
9362 if ( attr != null ) {
0 commit comments