Skip to content

Commit 22a133b

Browse files
committed
Switched .NET Standard 2.0 check to use accessibility
1 parent b7688ef commit 22a133b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Microsoft.Toolkit.Mvvm.SourceGenerators/Attributes/NullabilityAttributesGenerator.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ private void AddSourceCodeIfTypeIsNotPresent(GeneratorExecutionContext context,
3636
{
3737
// Check that the target attributes are not available in the consuming project. To ensure that
3838
// this works fine both in .NET (Core) and .NET Standard implementations, we also need to check
39-
// that the target types are defined in the reference assemblies for all target runtimes. This
40-
// avoids issues on .NET Standard with Roslyn also seeing internal types from referenced assemblies.
41-
if (context.Compilation.GetTypeByMetadataName(typeFullName) is
42-
{ ContainingModule: { MetadataName: "netstandard.dll" or "System.Runtime.dll" } })
39+
// that the target types are declared as public (we assume that in this case those types are from the BCL).
40+
// This avoids issues on .NET Standard with Roslyn also seeing internal types from referenced assemblies.
41+
if (context.Compilation.GetTypeByMetadataName(typeFullName) is { DeclaredAccessibility: Accessibility.Public })
4342
{
4443
return;
4544
}

0 commit comments

Comments
 (0)