-
Notifications
You must be signed in to change notification settings - Fork 397
Closed
Description
Description
When using Mapster (v10.0.4) in a .NET 7 project, a CS0433 compilation error occurs because the NotNullWhenAttribute is exposed publicly by the Mapster package, which collides with the built-in attribute in System.Runtime.
Steps to Reproduce
- Create a minimal
csprojfile targetingnet7.0:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mapster" Version="10.0.4" />
</ItemGroup>
</Project>- Add a simple test class utilizing the attribute:
using System.Diagnostics.CodeAnalysis;
namespace MapperTest;
public class Tests
{
public Tests()
{
}
protected virtual bool TryLoadAssembly(
string filePath,
[NotNullWhen(true)] out string assembly
)
{
assembly = null;
return false;
}
}
- Build the project.
Observed Behavior
The build fails with the following compiler error:
error CS0433: The type 'NotNullWhenAttribute' exists in both 'Mapster, Version=10.0.4.0, Culture=neutral, PublicKeyToken=2f39883af23c29a8' and 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Reactions are currently unavailable