-
Notifications
You must be signed in to change notification settings - Fork 36
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
Use .NET project files analyzers #145
base: master
Are you sure you want to change the base?
Conversation
Thanks, @Corniel . I will try to formulate my questions regardless of numerous changes, leading (in my opinion) to clogging projects with excessive settings.
So am I understand correctly that the whole purpose of that container/pseudo project is to be available to your analyzer/sdk?
But when I change it to
|
Thanks for looking into this! It is a challenge to come with suggestions/rules that fit all project setups. It helps to further improve .NET project file analyzers. As mentioned, 4 is a FP. But what is your reasoning to solve it like this? It might give inside in how to solve these kind of things? (I considered a rule that states that TargetFramework should not be conditional in the first place) |
.gitignore contains
It is conditional rather often.
Like how? What do you mean? I just follow warning from analyzer. |
I can't recall to see it before. But that might have to do with working on projects with different characteristics.
Purely out of interest: what is the reasoning to have different targets based on the OS? The reasoning about having conditionals only on level 1 is that it should improve readability; when defined on level 2, the value of what is conditional tends to be harder to read. Although I admit that in case of TargetFramework/TragetFrameworks, that is not per se the case. |
It's simple - packaging and/or testing on available OS'es from GitHub Actions os matrix. You can't run tests in .NET Framework runtime on Ubuntu but on Windows you can. |
Fair point. I'm still not sure what the best solution should be (recommended by the rule): <PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
<TargetFrameworks>net8.0;netstandard</TargetFrameworks>
<PropertyGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup> Using a choose when: <Choose>
<When Condition="'$(OS)' == 'Windows_NT'">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard</TargetFrameworks>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">net8.0</TargetFramework>
</PropertyGroup>
</Otherwise>
</Choose> Or as you did: <PropertyGroup>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net8.0;netstandard</TargetFrameworks>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">net8.0</TargetFramework>
</PropertyGroup> In this case it seems the lesser of the evils. But should I take that into account in the rule, and how? |
All variants are too verbose - less or more. I would completely ignore targetframework|s tags for this rule. I do not believe that anyone will bother changing well known simple approach living in codebases for ages. |
I agree, I've made a proposal to solve this FP: dotnet-project-file-analyzers/dotnet-project-file-analyzers#257 |
Including the use of the SDK.
Note that the solution file (and Directory.Build.props) have been move a dir up, so that all things inlcuded are not below the specfied root level).