-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable Roslyn analyzers in build process #11916
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
Conversation
833cc04 to
a174eb6
Compare
PowerShell.sln
Outdated
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.
Please revert this changes
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.
Only the line or all such lines?
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.
Reverted all.
TravisEz13
left a comment
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.
too big to review, PR review tool doesn't function
|
Perhaps you can enable one rule at a time to reduce the file changes. I cannot jump to files due to the large number of changes. |
|
@TravisEz13 You can review commit by commit. Yes, only one rule is forced in the PR. This add "readonly" qualifier. I will split the large commit by 20-30 files. |
a174eb6 to
47c88bc
Compare
|
Git hub doesn't have a mechanism for tracking reviews, commit by commit. I can see if reviewable still works. |
|
@PoshChan Please remind me in 2 days |
|
@TravisEz13, this is the reminder you requested 2 days ago |
47c88bc to
a6b8bc0
Compare
TravisEz13
left a comment
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.
Reviewed 31 of 366 files at r1.
Reviewable status: 31 of 366 files reviewed (waiting on @adityapatwardhan, @anmenaga, @daxian-dbw, @iSazonov, and @SteveL-MSFT)
|
I'll try to review a portion each day. |
|
@PoshChan Please remind me in 1 day. |
|
@TravisEz13, this is the reminder you requested 1 day. ago |
|
This PR does not seem to enable any analyzers during the build process. If it did then the build would fail since |
|
Currently IDE code style rules do not apply during builds, see dotnet/roslyn#33558 |
|
@xtqqczze Yes, you are right about that IDE rules. The PR is only initial for the enhancement of our build process. Later we can easily add other rules and force then as needed. Also I hope the .Net issue will fixed in some way. Update: the next Microsoft.CodeAnalysis.CSharp 3.6.0 will implement this in days. |
vexx32
left a comment
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.
Overall these changes look good. I have a couple questions/comments on a few of them. 🙂
| private readonly string _name; | ||
|
|
||
| /// <summary> | ||
| /// The string defining real cmdlet name. | ||
| /// </summary> | ||
| internal string Value { get { return this._value; } } | ||
|
|
||
| private string _value = string.Empty; | ||
| private readonly string _value = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// The string defining real cmdlet name. | ||
| /// </summary> | ||
| internal ScopedItemOptions Options { get { return this._options; } } | ||
|
|
||
| private ScopedItemOptions _options = ScopedItemOptions.AllScope | ScopedItemOptions.ReadOnly; | ||
| private readonly ScopedItemOptions _options = ScopedItemOptions.AllScope | ScopedItemOptions.ReadOnly; |
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.
Am I remembering wrong or was this file removed in a recent PR since it only functions to add command aliases, which were moved to attributes?
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.
It is still not merged.
| /// This is the default function to use for tab expansion. | ||
| /// </summary> | ||
| private static string s_tabExpansionFunctionText = @" | ||
| private static readonly string s_tabExpansionFunctionText = @" |
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 seems like something we'd have as const, no?
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.
It is static. If it is wrong we should fix this in another PR.
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.
Yeah that's why I asked. Maybe make a note of these and we can have another look in a later PR, see if it's worth making them const. 🙂
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.
It is used only once. I believe the const would be saved in a static area too and it makes no sense to change - we get no perf benefits.
| "; | ||
|
|
||
| private static string s_createCommandExistsInCurrentDirectoryScript = @" | ||
| private static readonly string s_createCommandExistsInCurrentDirectoryScript = @" |
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.
Should these strings be const?
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 same.
| internal struct CRYPT_PROVIDER_CERT | ||
| { | ||
| private DWORD _cbStruct; | ||
| private readonly DWORD _cbStruct; | ||
| internal IntPtr pCert; // PCCERT_CONTEXT | ||
| private BOOL _fCommercial; | ||
| private BOOL _fTrustedRoot; | ||
| private BOOL _fSelfSigned; | ||
| private BOOL _fTestCert; | ||
| private DWORD _dwRevokedReason; | ||
| private DWORD _dwConfidence; | ||
| private DWORD _dwError; | ||
| private IntPtr _pTrustListContext; // CTL_CONTEXT* | ||
| private BOOL _fTrustListSignerCert; | ||
| private IntPtr _pCtlContext; // PCCTL_CONTEXT | ||
| private DWORD _dwCtlError; | ||
| private BOOL _fIsCyclic; | ||
| private IntPtr _pChainElement; // PCERT_CHAIN_ELEMENT | ||
| private readonly BOOL _fCommercial; | ||
| private readonly BOOL _fTrustedRoot; | ||
| private readonly BOOL _fSelfSigned; | ||
| private readonly BOOL _fTestCert; | ||
| private readonly DWORD _dwRevokedReason; | ||
| private readonly DWORD _dwConfidence; | ||
| private readonly DWORD _dwError; | ||
| private readonly IntPtr _pTrustListContext; // CTL_CONTEXT* | ||
| private readonly BOOL _fTrustListSignerCert; | ||
| private readonly IntPtr _pCtlContext; // PCCTL_CONTEXT | ||
| private readonly DWORD _dwCtlError; | ||
| private readonly BOOL _fIsCyclic; | ||
| private readonly IntPtr _pChainElement; // PCERT_CHAIN_ELEMENT |
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.
We don't provide a constructor to set these and they're readonly. How would these be set?
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.
Same question for the rest of the structs in this file actually.
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'd ask why they private :-)
Looks like false positives.
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.
Yeah both are good questions here 😁
Not sure how this struct is actually used to be honest, but I don't see how it would be useful at the moment.
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.
In fact, all these structures are created in P/Invoke, they are really readonly for C# and "private" here is "named unused".
I believe we can accept the change.
|
@TravisEz13 Could you please continue? |
|
@iSazonov something to be aware of: dotnet/roslyn#43051 |
|
@xtqqczze Thanks! We use |
|
@TravisEz13 Could you please continue the code review? |
TravisEz13
left a comment
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.
Reviewed 35 of 366 files at r1.
Reviewable status: 57 of 366 files reviewed (waiting on @adityapatwardhan, @anmenaga, @daxian-dbw, @iSazonov, @SteveL-MSFT, @TravisEz13, and @vexx32)
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
PR Context
Analyzers help to make code high quality.
See .Net Runtime experience dotnet/runtime#30740
We should benefit from C# analyzers too.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.This change is