-
Notifications
You must be signed in to change notification settings - Fork 36
Use .NET project files analyzers #145
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
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 |
|
This pull request was marked as stale since it has not been active for a long time |
bc496ac to
2ac01b1
Compare
2ac01b1 to
43d0ffa
Compare
280d784 to
5ebbced
Compare
|
@sungam3r I think this should be okay to merge. There are some warnings left that I think are valid, but should not be merged with this PR (like that the package icon is advised to be 256x256). |
| <RootNamespace>Destructurama</RootNamespace> | ||
| <IsPackable>true</IsPackable> | ||
| <PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes> | ||
| <PackageId>Destructurama.Attributed</PackageId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PackageId>Destructurama.Attributed</PackageId> |
The vast majority of the projects which I work on avoid this property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
| <PackageReleaseNotes> | ||
| <![CDATA[ | ||
| v1.0 | ||
| - Migrated from Serilog.Extras.Attributed at serilog/serilog. | ||
| ]]> | ||
| </PackageReleaseNotes> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, no, please, let's not clog configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sungam3r How would you like to solve your release notes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All release notes are in releases: https://github.com/destructurama/attributed/releases
They are generated/formatted automatically via GitHub when I publish release. Simply speaking it is not the best solution to put the history of releases inside the package itself (at least when you use GitHub releases expirience).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if it ignores the <ReleaseNotes> tag completealy? In that case, just adding a single statement there works perfectly as explanation on how it is solved. It should also be added to our documentation obviously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What "it"? GitHub releases feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. SO bu just having <PackageReleaseNotes>Handled by GitHub release</PackageReleaseNotes> you should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github release experience knows nothing about nuget/project structure.
Handled by GitHub release
It is nothing more that stub just to satisfy opionated rule, but OK, in such form it may have value, a little.
| @@ -0,0 +1,30 @@ | |||
| <Project> | |||
| <PropertyGroup> | |||
| <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All that file and things around central package management feature are too verbose and honestly excessive for small projects. I won't bring anything regarding central package management in repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm under the impression that MS is heading in that direction. That being said, I agree that it can feel as overhead for small projects (although I'm happy that I switched myself for some of my small projects).
I think the main issue with some of the more opinionated rules is that due to some crappy support by MS, it is less trivial to disable (or enable) rules in a .globalconfig or .editorconfig file. For rules about C# code this works perfectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine disabling rules by NoWarn as I did here #143.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having it in a .globalconfig file is way more readable: https://github.com/Qowaiv/Qowaiv/blob/master/.globalconfig
In a <NoWarn> tag, you can not easily see which rules are disabled. I still have to take some action to report this to MS with a simple analyzer that makes it easy for them to reproduce the issue and hopefully fix it (or show me another way other than <NoWarn>).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is way more readable
I don't want to speculate around what way is more readable or not. Experience varies.
|
@Corniel Thanks for you work. I want to make clarity here. When I saw project analyzer repo, I expected to get useful tips from it that would allow me to improve the project structure without destructive actions like you demonstrated in that PR. Compare it to #143 - / and \ slashes - OK, some changes in Also I would like to solve dotnet-project-file-analyzers/dotnet-project-file-analyzers#257 first. I see many analyzer rules are so opionated that my development experience does not allow me to force such rules, because in my opinion, such forcing only harms. Nevertheless, having read documentation to all the rules, I found some really useful there. |
Thanks for your feedback, I'm really happy you take the time to give it. As mentioned in an other response. When I started I was under the impression that disable rules you don't like is easy, so that should not be a problem. As it turns out, that now seems not even close to as easy to do, as it should, which makes that we should potentially reconsider some rules. I'm thinking of ways to make this easier. The use of |
Really? What is complicated there? |
Well, as mentioned, you can use |
Not applicable. I know what I do and why. I just disable rules that I do not need. That's all. |
|
This pull request was marked as stale since it has not been active for a long time |
|
This pull request was marked as stale since it has not been active for a long time |
|
This pull request was marked as stale since it has not been active for a long time |
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).