WIP: Enable CA1507: Use nameof to express symbol names#13875
WIP: Enable CA1507: Use nameof to express symbol names#13875xtqqczze wants to merge 1 commit intoPowerShell:masterfrom
Conversation
src/Microsoft.Management.UI.Internal/HelpWindow/HelpViewModel.cs
Outdated
Show resolved
Hide resolved
| { | ||
| WildcardPattern wildcardpattern = WildcardPattern.Get(desc, WildcardOptions.IgnoreCase); | ||
| if (wildcardpattern.IsMatch((string)obj["Description"])) | ||
| if (wildcardpattern.IsMatch((string)obj[nameof(Description)])) |
There was a problem hiding this comment.
Here Description is a property name of ManagementObject.
Or can it be:
| if (wildcardpattern.IsMatch((string)obj[nameof(Description)])) | |
| if (wildcardpattern.IsMatch((string)obj[nameof(obj.Description)])) |
Also what about "InstalledBy" in the file?
I suggest to revert such non-obvious changes here and below because we can break something tricky.
| get | ||
| { | ||
| return (bool)_graphicalHostReflectionWrapper.GetPropertyValue("HasHostWindow"); | ||
| return (bool)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(HasHostWindow)); |
There was a problem hiding this comment.
The same. HasHostWindow is a property of GraphicalHostReflectionWrapper.
I see the same patterns below.
| RemotingEncoder.AddNoteProperty<object>(dest, "TargetObject", delegate () { return TargetObject; }); | ||
| RemotingEncoder.AddNoteProperty<string>(dest, "FullyQualifiedErrorId", delegate () { return FullyQualifiedErrorId; }); | ||
| RemotingEncoder.AddNoteProperty<InvocationInfo>(dest, "InvocationInfo", delegate () { return InvocationInfo; }); | ||
| RemotingEncoder.AddNoteProperty<Exception>(dest, nameof(Exception), delegate () { return Exception; }); |
There was a problem hiding this comment.
Again, is the reference to Exception right?
Below in the file too.
| informationRecord.ProcessId = RemotingDecoder.GetPropertyValue<uint>(inputObject, "ProcessId"); | ||
| informationRecord.NativeThreadId = RemotingDecoder.GetPropertyValue<uint>(inputObject, "NativeThreadId"); | ||
| informationRecord.ManagedThreadId = RemotingDecoder.GetPropertyValue<uint>(inputObject, "ManagedThreadId"); | ||
| informationRecord.User = RemotingDecoder.GetPropertyValue<string>(inputObject, nameof(User)); |
|
@xtqqczze Please address my comments. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
@xtqqczze Can we continue? If there are doubts please revert and suppress locally. |
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1507
Follow-up #12716