Skip to content

Compilation Error on .NET Framework #495

@xmine64

Description

@xmine64

Describe the bug

When using .NET Framework 4.8 project build fails with the following errors:

Errors Log ...\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.NullabilityAttributesGenerator\System.Diagnostics.CodeAnalysis.NotNullAttribute.g.cs(12,27): error CS0101: The namespace 'System.Diagnostics.CodeAnalysis' already contains a definition for 'NotNullAttribute'

...\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.NullabilityAttributesGenerator\System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute.g.cs(11,27): error CS0101: The namespace 'System.Diagnostics.CodeAnalysis' already contains a definition for 'NotNullIfNotNullAttribute'

...\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.NullabilityAttributesGenerator\System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute.g.cs(10,6): error CS0579: Duplicate 'AttributeUsage' attribute

...\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.NullabilityAttributesGenerator\System.Diagnostics.CodeAnalysis.NotNullAttribute.g.cs(11,6): error CS0579: Duplicate 'AttributeUsage' attribute

...\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.NullabilityAttributesGenerator\System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute.g.cs(17,16): error CS0111: Type 'NotNullIfNotNullAttribute' already defines a member called 'NotNullIfNotNullAttribute' with the same parameter types

Everything is fine when using .NET 6, I guess the code generator is not compatible with .NET Framework when I have <Nullable>enable</Nullable> and <LangVersion>9</LangVersion> but not sure, needs to be tested.

Regression

No response

Steps to reproduce

1. Create a .NET Framework 4.8 project with `<Nullable>enable</Nullable>` and `<LangVersion>9</LangVersion>`.
2. Add CommunityToolkit.Mvvm 8.0.0 NuGet package
3. Try to build it.

Expected behavior

The app should get built without any problem.

Screenshots

No response

IDE and version

VS 2022

IDE version

17.3.1

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.0.0

Additional context

No response

Help us help you

No, just wanted to report this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behaviorduplicate 👥Indicates that an identical issue or PR already existsmvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions