Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting .netstandard2.0 package removes most CAXXXX rules #7409

Open
olstakh opened this issue Sep 5, 2024 · 0 comments
Open

Targeting .netstandard2.0 package removes most CAXXXX rules #7409

olstakh opened this issue Sep 5, 2024 · 0 comments

Comments

@olstakh
Copy link

olstakh commented Sep 5, 2024

This might be a duplicate or by design, didn't find concrete answer.

TL;DR: Adding a nuget package reference that targets .netstandard2.0 removes most CAXXXX rules

Csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <NoWarn>$(NoWarn);NU1605</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0.0" />
    
    <!--
      Adding below package reference causes the compiler error to disappear.
      Remove below package reference to reproduce the compiler error.
      Is it because this package is built for .netstandard2.0?
    -->
    <PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.33" />
  </ItemGroup>
</Project>

Violations of CA2254 (and others) disappear when reference to (in this case) Microsoft.Azure.WebJobs is included in the project (can be someone else's dependency too). Removing this package reference restores compiler error (in this case of CA2254).

Is there some msbuild property i can set to preserve the proper ruleset? Seems not right to lose a lot of rules by simply having .netstandard2.0 transient nuget package dependency in the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant