@@ -29,31 +29,31 @@ public sealed class NullabilityAttributesGenerator : IIncrementalGenerator
29
29
/// <inheritdoc/>
30
30
public void Initialize ( IncrementalGeneratorInitializationContext context )
31
31
{
32
- // Check that the target attributes are not available in the consuming project. To ensure that
33
- // this works fine both in .NET (Core) and .NET Standard implementations, we also need to check
34
- // that the target types are declared as public (we assume that in this case those types are from the BCL).
32
+ // Check that the target attributes are not available in the consuming project. To ensure that this
33
+ // works fine both in .NET (Core) and .NET Standard implementations, we also need to check that the
34
+ // target types are declared as public (we assume that in this case those types are from the BCL).
35
35
// This avoids issues on .NET Standard with Roslyn also seeing internal types from referenced assemblies.
36
36
37
- // Check whether [NotNull] is available
38
- IncrementalValueProvider < bool > isNotNullAttributeAvailable =
37
+ // Check whether [NotNull] is not available
38
+ IncrementalValueProvider < bool > isNotNullAttributeNotAvailable =
39
39
context . CompilationProvider
40
- . Select ( static ( item , _ ) => item . HasAccessibleTypeWithMetadataName ( NotNullAttributeMetadataName ) ) ;
40
+ . Select ( static ( item , _ ) => ! item . HasAccessibleTypeWithMetadataName ( NotNullAttributeMetadataName ) ) ;
41
41
42
42
// Generate the [NotNull] type
43
- context . RegisterConditionalSourceOutput ( isNotNullAttributeAvailable , static context =>
43
+ context . RegisterConditionalSourceOutput ( isNotNullAttributeNotAvailable , static context =>
44
44
{
45
45
string source = LoadAttributeSourceWithMetadataName ( NotNullAttributeMetadataName ) ;
46
46
47
47
context . AddSource ( NotNullAttributeMetadataName , source ) ;
48
48
} ) ;
49
49
50
- // Check whether [NotNullIfNotNull] is available
51
- IncrementalValueProvider < bool > isNotNullIfNotNullAttributeAvailable =
50
+ // Check whether [NotNullIfNotNull] is not available
51
+ IncrementalValueProvider < bool > isNotNullIfNotNullAttributeNotAvailable =
52
52
context . CompilationProvider
53
- . Select ( static ( item , _ ) => item . HasAccessibleTypeWithMetadataName ( NotNullIfNotNullAttributeMetadataName ) ) ;
53
+ . Select ( static ( item , _ ) => ! item . HasAccessibleTypeWithMetadataName ( NotNullIfNotNullAttributeMetadataName ) ) ;
54
54
55
55
// Generate the [NotNullIfNotNull] type
56
- context . RegisterConditionalSourceOutput ( isNotNullIfNotNullAttributeAvailable , static context =>
56
+ context . RegisterConditionalSourceOutput ( isNotNullIfNotNullAttributeNotAvailable , static context =>
57
57
{
58
58
string source = LoadAttributeSourceWithMetadataName ( NotNullIfNotNullAttributeMetadataName ) ;
59
59
0 commit comments