-
Notifications
You must be signed in to change notification settings - Fork 698
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
Enforce IDE0005 during build by enabling GenerateDocumentationFile #5854
Conversation
src/NuGet.Clients/NuGet.CommandLine/CommandLineMachineWideSettings.cs
Outdated
Show resolved
Hide resolved
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.
The PR checklist is not filled out, and personally I find the PR title misleading, as it's just enabling XMLDoc generation for two projects, but it's not enabling style rules more broadly (style rules other than XMLDoc comments to the two projects, and it's not clear to me why just these two projects, rather than most src/NuGet.Core/*
projects)
src/NuGet.Clients/NuGet.CommandLine/CommandLineMachineWideSettings.cs
Outdated
Show resolved
Hide resolved
249a398
to
b3f9a76
Compare
@@ -7,6 +7,7 @@ | |||
<PackProject>true</PackProject> | |||
<Shipping>true</Shipping> | |||
<IncludeInVSIX>true</IncludeInVSIX> | |||
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
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.
The linked issue isn't clearly defined, making it sound like the intention is to enforce all style rules, not just documentation files, and also across all projects, not just one or two. The PR description also doesn't explain either why only XMLDoc, or why only 1 or 2 projects.
Most of the src/NuGet.Core/*
projects are nupkgs published to nuget.org. Do the other project already generate XMLDoc, and NuGet.Versioning was the only one that wasn't?
Should the linked issue be changed to explicitly mention it's only about XMLDoc, and not other style issues?
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 agree with Andy that we should clarify the scope of the PR/issue.
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.
Okay I updated the issue. I don't really have a reason why I picked these two projects, I just needed to start somewhere.
One thing though, a know that is set to true for projects with set to true
NuGet.Client/build/common.targets
Lines 39 to 42 in 15ad272
<PropertyGroup Condition=" '$(PackProject)' == 'true' "> | |
<GenerateDocumentationFile Condition=" '$(GenerateDocumentationFile)' == '' ">true</GenerateDocumentationFile> | |
<DocumentationFile Condition=" '$(DocumentationFile)' == '' AND '$(GenerateDocumentationFile)' == 'true' AND '$(IsNetCoreProject)' != 'true' ">$(OutputPath)\$(AssemblyName).xml</DocumentationFile> | |
</PropertyGroup> |
Despite that I still don't get build errors for using statements until I specify GenerateDocumentationFile in the csproj.
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.
can you upload a binlog for the project in question?
You can do it in teams if that's easier.
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.
Okay I moved this pack from the common.targets to common.project.props, and that worked. Is there a better location for it? Basically, we need to set it in a different location because it's getting set by another config.
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.
Keep in mind that the NuGet.Client repo has existed for years, before the .NET (Core) SDK was a thing, so while the SDK might now have defaults to make it work out of the box, perhaps in the past it didn't, or pre-SDK style projects might have worked differently as well.
I prefer a common config to apply to all projects, rather than opting individual projects into docs.
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.
Moving the code to the common.project.props file doesn't work because when it goes to evaluate the condition is empty, so is set to false in Microsoft.NET.Sdk.BeforeCommon.targets.
Which condition is false?
This one, since PackProject is set later in the file it has no value when this is evaluated.
<PropertyGroup Condition=" '$(PackProject)' == 'true' ">
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 prefer a common config to apply to all projects, rather than opting individual projects into docs.
Agreed but where that common config should live is difficult because of how <GenerateDocumentationFile>
is set by Microsoft.NET.Sdk.BeforeCommon.targets
.
Since we now know that without <GenerateDocumentationFile>
we can't enforce all the style rules, is it worth just enabling it for everyone?
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 think it's ok to enable it for everyone.
We'd probably need to disable the IDE0005 in some projects where it fails,.
I can't think of anything else.
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.
@zivkan to focus this conversation here because this has the most context. So, the latest change I pushed is what it looks like if we enable GenerateDocumentationFile
for all projects all at once. I kept flipping back and forth between enabling it per project then once all projects have had it enabled moving it to the central build props project.
Currently we do not generate the documentation file for any of our projects because of the way the value is determined. So, I believe options for moving forward are:
- Enable
GenerateDocumentationFile
for all projects, usingNoWarn
to suppress build errors, then overtime remove the suppressions per project and fix the errors that come up. (current state) - Enable
GenerateDocumentationFile
for all projects, usingWarningsNotAsErrors
to suppress build errors, then overtime remove the suppressions per project and fix the errors that come up. - Enable
GenerateDocumentationFile
for individual projects, fixing the build errors as it is enabled. Once all projects have been updated to generate documentation files, we can move it to a central location. - Force
GenerateDocumentationFile
to true for projects which havePackProject
set to true. This will limit the scope of how many projects need to be fixed upfront, however it will still be a lot. We would need to selectively turn onGenerateDocumentationFile
for all projects in order to get the style fixes like IDE0005 to show up as errors in the build.
This reverts commit 4f91a03.
@@ -24,7 +24,8 @@ | |||
<UsePublicApiAnalyzer>false</UsePublicApiAnalyzer> | |||
<GetSigningInputsDependsOn>GetSigningInputsCustom</GetSigningInputsDependsOn> | |||
<GetSymbolsToIndexDependsOn>GetSymbolsToIndexCustom</GetSymbolsToIndexDependsOn> | |||
</PropertyGroup> | |||
<NoWarn>$(NoWarn);CS1591;IDE0059;IDE1006;IDE0049</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.
CS1591 is related to XMLDoc, and therefore the title of this PR, but the other 3 codes are not.
We want to keep IDE1006, so disabling for the whole project feels wrong. I know we've got a bunch of noise on static properties, but we want to keep warnings (ideally enforce) public properties being Pascal Case, private members being _camelCase, methods being Pascal Case.
An in my opinion, IDE0059 seems like a good analyzer we should keep.
I think IDE0049 is very reasonable too, though we've got a lot of violations in our repo. But suppressing the code increases risk that future code changes will continue to add more violations, making it harder to enforce in the future.
@@ -44,4 +45,4 @@ | |||
ItemName="ReferencesCopiedInThisBuild" /> | |||
</Copy> | |||
</Target> | |||
</Project> | |||
</Project> |
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.
let's keep trailing new line. I thought our editorconfig actually specifies this
<!-- Write out .XML files for projects that will be packed. --> | ||
<PropertyGroup> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<DocumentationFile Condition=" '$(DocumentationFile)' == '' AND '$(GenerateDocumentationFile)' == 'true' AND '$(IsNetCoreProject)' != 'true' ">$(OutputPath)\$(AssemblyName).xml</DocumentationFile> |
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 think it's a great thing to enforce XMLDoc for the packages we publish to nuget.org. However,
- This issue is titled enforce IDE0005, but the docs say IDE0005 is about removing unnecessary usings, which has nothing to do with XMLDoc, and therefore the title "enforce IDE005 by enabling GenerateDocumentationFile" doesn't make sense
- I don't see anything in this PR that changes enforcement of IDE005. Our CI builds will continue to pass after this merges if people add new violations in future PRs.
- To be honest, I'm not a fan of adding NoWarn. I see NoWarn as tech debt, so now that I see the consequence of enabling
GenerateDocumentationFile
to all projects in the solution, I prefer the old implementation where it's only selectively enabled for projects that are packed.
@@ -9,6 +9,7 @@ | |||
<TargetFramework>$(NETFXTargetFramework)</TargetFramework> | |||
<UseWpf>true</UseWpf> | |||
<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild> | |||
<NoWarn>$(NoWarn);CS1572;CS1573;CS1591;IDE0005;IDE1006</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.
The PR title says it's enforcing IDE0005, but it's just being suppressed here, not enforced.
$(PkgMicrosoft_Test_Apex_VisualStudio)\lib\net46\Microsoft.Test.Apex.RemoteCodeInjector.dll; | ||
$(PkgMicrosoft_Test_Apex_VisualStudio)\lib\net46\Microsoft.Test.Apex.RemoteCodeInjector.x64.dll" | ||
Name="%(Filename)" /> | ||
<Reference Include="$(PkgMicrosoft_Test_Apex_VisualStudio)\lib\net46\*.dll" Exclude="$(PkgMicrosoft_Test_Apex_VisualStudio)\lib\net46\Microsoft.Test.Apex.PrismIntegration.dll;
 $(PkgMicrosoft_Test_Apex_VisualStudio)\lib\net46\Microsoft.Test.Apex.RemoteCodeInjector.dll;
 $(PkgMicrosoft_Test_Apex_VisualStudio)\lib\net46\Microsoft.Test.Apex.RemoteCodeInjector.x64.dll" Name="%(Filename)" /> |
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.
This looks like a bad change.
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
Bug
Fixes: https://github.com/NuGet/Client.Engineering/issues/2845
Regression? Last working version:
Description
Updated two projects to include style rules enforcement during build, fixing the build errors for those two projects. Currently certain rules are not enforced unless XML documents are generated, dotnet/roslyn#41640.
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation