-
Notifications
You must be signed in to change notification settings - Fork 8.1k
WIP: Enable CA1507: Use nameof to express symbol names #13875
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,55 +89,55 @@ internal bool HasHostWindow | |
| { | ||
| get | ||
| { | ||
| return (bool)_graphicalHostReflectionWrapper.GetPropertyValue("HasHostWindow"); | ||
| return (bool)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(HasHostWindow)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same. HasHostWindow is a property of GraphicalHostReflectionWrapper. I see the same patterns below. |
||
| } | ||
| } | ||
|
|
||
| internal AutoResetEvent WindowClosed | ||
| { | ||
| get | ||
| { | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue("WindowClosed"); | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(WindowClosed)); | ||
| } | ||
| } | ||
|
|
||
| internal AutoResetEvent HelpNeeded | ||
| { | ||
| get | ||
| { | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue("HelpNeeded"); | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(HelpNeeded)); | ||
| } | ||
| } | ||
|
|
||
| internal AutoResetEvent ImportModuleNeeded | ||
| { | ||
| get | ||
| { | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue("ImportModuleNeeded"); | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(ImportModuleNeeded)); | ||
| } | ||
| } | ||
|
|
||
| internal AutoResetEvent WindowLoaded | ||
| { | ||
| get | ||
| { | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue("WindowLoaded"); | ||
| return (AutoResetEvent)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(WindowLoaded)); | ||
| } | ||
| } | ||
|
|
||
| internal string CommandNeedingHelp | ||
| { | ||
| get | ||
| { | ||
| return (string)_graphicalHostReflectionWrapper.GetPropertyValue("CommandNeedingHelp"); | ||
| return (string)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(CommandNeedingHelp)); | ||
| } | ||
| } | ||
|
|
||
| internal string ParentModuleNeedingImportModule | ||
| { | ||
| get | ||
| { | ||
| return (string)_graphicalHostReflectionWrapper.GetPropertyValue("ParentModuleNeedingImportModule"); | ||
| return (string)_graphicalHostReflectionWrapper.GetPropertyValue(nameof(ParentModuleNeedingImportModule)); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -175,15 +175,15 @@ internal double ScreenWidth | |
| { | ||
| get | ||
| { | ||
| return (double)_graphicalHostReflectionWrapper.GetStaticPropertyValue("ScreenWidth"); | ||
| return (double)_graphicalHostReflectionWrapper.GetStaticPropertyValue(nameof(ScreenWidth)); | ||
| } | ||
| } | ||
|
|
||
| internal double ScreenHeight | ||
| { | ||
| get | ||
| { | ||
| return (double)_graphicalHostReflectionWrapper.GetStaticPropertyValue("ScreenHeight"); | ||
| return (double)_graphicalHostReflectionWrapper.GetStaticPropertyValue(nameof(ScreenHeight)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1204,10 +1204,10 @@ internal void ToPSObjectForRemoting(PSObject dest) | |
|
|
||
| private void ToPSObjectForRemoting(PSObject dest, bool serializeExtInfo) | ||
| { | ||
| RemotingEncoder.AddNoteProperty<Exception>(dest, "Exception", delegate () { return Exception; }); | ||
| 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; }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, is the reference to Exception right? |
||
| RemotingEncoder.AddNoteProperty<object>(dest, nameof(TargetObject), delegate () { return TargetObject; }); | ||
| RemotingEncoder.AddNoteProperty<string>(dest, nameof(FullyQualifiedErrorId), delegate () { return FullyQualifiedErrorId; }); | ||
| RemotingEncoder.AddNoteProperty<InvocationInfo>(dest, nameof(InvocationInfo), delegate () { return InvocationInfo; }); | ||
| RemotingEncoder.AddNoteProperty<int>(dest, "ErrorCategory_Category", delegate () { return (int)CategoryInfo.Category; }); | ||
| RemotingEncoder.AddNoteProperty<string>(dest, "ErrorCategory_Activity", delegate () { return CategoryInfo.Activity; }); | ||
| RemotingEncoder.AddNoteProperty<string>(dest, "ErrorCategory_Reason", delegate () { return CategoryInfo.Reason; }); | ||
|
|
@@ -1223,13 +1223,13 @@ private void ToPSObjectForRemoting(PSObject dest, bool serializeExtInfo) | |
|
|
||
| if (!serializeExtInfo || this.InvocationInfo == null) | ||
| { | ||
| RemotingEncoder.AddNoteProperty(dest, "SerializeExtendedInfo", () => false); | ||
| RemotingEncoder.AddNoteProperty(dest, nameof(SerializeExtendedInfo), () => false); | ||
| } | ||
| else | ||
| { | ||
| RemotingEncoder.AddNoteProperty(dest, "SerializeExtendedInfo", () => true); | ||
| RemotingEncoder.AddNoteProperty(dest, nameof(SerializeExtendedInfo), () => true); | ||
| this.InvocationInfo.ToPSObjectForRemoting(dest); | ||
| RemotingEncoder.AddNoteProperty<object>(dest, "PipelineIterationInfo", delegate () { return PipelineIterationInfo; }); | ||
| RemotingEncoder.AddNoteProperty<object>(dest, nameof(PipelineIterationInfo), delegate () { return PipelineIterationInfo; }); | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(this.ScriptStackTrace)) | ||
|
|
@@ -1291,10 +1291,10 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) | |
| } | ||
|
|
||
| // Get Exception | ||
| PSObject serializedException = RemotingDecoder.GetPropertyValue<PSObject>(serializedErrorRecord, "Exception"); | ||
| PSObject serializedException = RemotingDecoder.GetPropertyValue<PSObject>(serializedErrorRecord, nameof(Exception)); | ||
|
|
||
| // Get Target object | ||
| object targetObject = RemotingDecoder.GetPropertyValue<object>(serializedErrorRecord, "TargetObject"); | ||
| object targetObject = RemotingDecoder.GetPropertyValue<object>(serializedErrorRecord, nameof(TargetObject)); | ||
|
|
||
| string exceptionMessage = null; | ||
| if (serializedException != null) | ||
|
|
@@ -1307,7 +1307,7 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) | |
| } | ||
|
|
||
| // Get FullyQualifiedErrorId | ||
| string fullyQualifiedErrorId = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "FullyQualifiedErrorId") ?? | ||
| string fullyQualifiedErrorId = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, nameof(FullyQualifiedErrorId)) ?? | ||
| "fullyQualifiedErrorId"; | ||
|
|
||
| // Get ErrorCategory... | ||
|
|
@@ -1323,7 +1323,7 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) | |
| // Get InvocationInfo (optional property) | ||
| PSObject invocationInfo = Microsoft.PowerShell.DeserializingTypeConverter.GetPropertyValue<PSObject>( | ||
| serializedErrorRecord, | ||
| "InvocationInfo", | ||
| nameof(InvocationInfo), | ||
| Microsoft.PowerShell.DeserializingTypeConverter.RehydrationFlags.MissingPropertyOk); | ||
|
|
||
| // Get Error Detail (these note properties are optional, so can't right now use RemotingDecoder...) | ||
|
|
@@ -1359,13 +1359,13 @@ private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord) | |
| // | ||
| // Get the InvocationInfo | ||
| // | ||
| _serializeExtendedInfo = RemotingDecoder.GetPropertyValue<bool>(serializedErrorRecord, "SerializeExtendedInfo"); | ||
| _serializeExtendedInfo = RemotingDecoder.GetPropertyValue<bool>(serializedErrorRecord, nameof(SerializeExtendedInfo)); | ||
|
|
||
| if (_serializeExtendedInfo) | ||
| { | ||
| _invocationInfo = new InvocationInfo(serializedErrorRecord); | ||
|
|
||
| ArrayList iterationInfo = RemotingDecoder.GetPropertyValue<ArrayList>(serializedErrorRecord, "PipelineIterationInfo"); | ||
| ArrayList iterationInfo = RemotingDecoder.GetPropertyValue<ArrayList>(serializedErrorRecord, nameof(PipelineIterationInfo)); | ||
| if (iterationInfo != null) | ||
| { | ||
| _pipelineIterationInfo = new ReadOnlyCollection<int>((int[])iterationInfo.ToArray(typeof(Int32))); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,22 +179,22 @@ internal static InformationRecord FromPSObjectForRemoting(PSObject inputObject) | |
| { | ||
| InformationRecord informationRecord = new InformationRecord(); | ||
|
|
||
| informationRecord.MessageData = RemotingDecoder.GetPropertyValue<object>(inputObject, "MessageData"); | ||
| informationRecord.Source = RemotingDecoder.GetPropertyValue<string>(inputObject, "Source"); | ||
| informationRecord.TimeGenerated = RemotingDecoder.GetPropertyValue<DateTime>(inputObject, "TimeGenerated"); | ||
| informationRecord.MessageData = RemotingDecoder.GetPropertyValue<object>(inputObject, nameof(MessageData)); | ||
| informationRecord.Source = RemotingDecoder.GetPropertyValue<string>(inputObject, nameof(Source)); | ||
| informationRecord.TimeGenerated = RemotingDecoder.GetPropertyValue<DateTime>(inputObject, nameof(TimeGenerated)); | ||
|
|
||
| informationRecord.Tags = new List<string>(); | ||
| System.Collections.ArrayList tagsArrayList = RemotingDecoder.GetPropertyValue<System.Collections.ArrayList>(inputObject, "Tags"); | ||
| System.Collections.ArrayList tagsArrayList = RemotingDecoder.GetPropertyValue<System.Collections.ArrayList>(inputObject, nameof(Tags)); | ||
| foreach (string tag in tagsArrayList) | ||
| { | ||
| informationRecord.Tags.Add(tag); | ||
| } | ||
|
|
||
| informationRecord.User = RemotingDecoder.GetPropertyValue<string>(inputObject, "User"); | ||
| informationRecord.Computer = RemotingDecoder.GetPropertyValue<string>(inputObject, "Computer"); | ||
| 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)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same. |
||
| informationRecord.Computer = RemotingDecoder.GetPropertyValue<string>(inputObject, nameof(Computer)); | ||
| informationRecord.ProcessId = RemotingDecoder.GetPropertyValue<uint>(inputObject, nameof(ProcessId)); | ||
| informationRecord.NativeThreadId = RemotingDecoder.GetPropertyValue<uint>(inputObject, nameof(NativeThreadId)); | ||
| informationRecord.ManagedThreadId = RemotingDecoder.GetPropertyValue<uint>(inputObject, nameof(ManagedThreadId)); | ||
|
|
||
| return informationRecord; | ||
| } | ||
|
|
||
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.
Here Description is a property name of ManagementObject.
Or can it be:
Also what about "InstalledBy" in the file?
I suggest to revert such non-obvious changes here and below because we can break something tricky.