microsoft / kiota-abstractions-dotnet

Abstractions library for the Kiota generated SDKs in dotnet
https://aka.ms/kiota/docs
MIT License
24 stars 21 forks source link

Project condition for IsTrimmable is incorrect #188

Closed hwoodiwiss closed 5 months ago

hwoodiwiss commented 5 months ago

Current Behaviour

Currently IsTrimmable is not set on a number of the Microsoft.Kiota .NET libraries as they share this incorrect condition:

<PropertyGroup Condition="'$(TargetFrameworkVersion)' == 'net5.0'">  
  <IsTrimmable>true</IsTrimmable>
</PropertyGroup>

Expected Behaviour

I would expect build errors when non-trim-safe code as added to the libraries.

Fix

The property group condition should be changed to:

<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">  
  <IsTrimmable>true</IsTrimmable>
</PropertyGroup>

Which causes the IsTrimmable property to be correctly set, and any expected trimming related compilation failures to occur.

I've found this issue in these projects:

baywet commented 5 months ago

For additional context: while the property being used exists in some contexts it seems it wasn't the right one https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#targetframework

Additional evidence https://www.aloneguid.uk/posts/2022/08/csproj-condition-cheat-sheet/