提交 6856054b 编写于 作者: C CyrusNajmabadi

Merge pull request #3937 from CyrusNajmabadi/nameof

Use nameof instead of hardcoded argument names.
......@@ -215,7 +215,7 @@ public static SyntaxTokenList Insert(this SyntaxTokenList list, int index, param
if (items == null)
{
throw new ArgumentNullException("items");
throw new ArgumentNullException(nameof(items));
}
if (list.Count == 0)
......
......@@ -484,7 +484,7 @@ protected override bool HasPreprocessorCharacter(ITextSnapshotLine currentLine)
{
if (currentLine == null)
{
throw new ArgumentNullException("currentLine");
throw new ArgumentNullException(nameof(currentLine));
}
var text = currentLine.GetText();
......
......@@ -203,7 +203,7 @@ public static void CollectCommentRegions(SyntaxNode node, List<OutliningSpan> sp
{
if (node == null)
{
throw new ArgumentNullException("node");
throw new ArgumentNullException(nameof(node));
}
var triviaList = node.GetLeadingTrivia();
......
......@@ -25,12 +25,12 @@ public CommandArgs(ITextView textView, ITextBuffer subjectBuffer)
{
if (textView == null)
{
throw new ArgumentNullException("textView");
throw new ArgumentNullException(nameof(textView));
}
if (subjectBuffer == null)
{
throw new ArgumentNullException("subjectBuffer");
throw new ArgumentNullException(nameof(subjectBuffer));
}
this.TextView = textView;
......
......@@ -21,7 +21,7 @@ public ExportContentTypeLanguageServiceAttribute(string defaultContentType, stri
{
if (defaultContentType == null)
{
throw new ArgumentNullException("defaultContentType");
throw new ArgumentNullException(nameof(defaultContentType));
}
this.DefaultContentType = defaultContentType;
......
......@@ -16,7 +16,7 @@ public ExportBraceMatcherAttribute(string language)
{
if (language == null)
{
throw new ArgumentNullException("language");
throw new ArgumentNullException(nameof(language));
}
this.Language = language;
......
......@@ -18,12 +18,12 @@ public ExportCompletionProviderAttribute(string name, string language)
{
if (name == null)
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException("language");
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
......
......@@ -18,7 +18,7 @@ public ExportHighlighterAttribute(string language)
{
if (language == null)
{
throw new ArgumentNullException("language");
throw new ArgumentNullException(nameof(language));
}
this.Language = language;
......
......@@ -17,12 +17,12 @@ public ExportQuickInfoProviderAttribute(string name, string language)
{
if (name == null)
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException("language");
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
......
......@@ -17,12 +17,12 @@ public ExportSignatureHelpProviderAttribute(string name, string language)
{
if (name == null)
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException("language");
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
......
......@@ -29,7 +29,7 @@ internal abstract class AbstractDiagnosticsTaggerProvider<TTag> :
{
if (subjectBuffer == null)
{
throw new ArgumentNullException("subjectBuffer");
throw new ArgumentNullException(nameof(subjectBuffer));
}
return this.GetOrCreateTagger<T>(null, subjectBuffer);
......
......@@ -122,7 +122,7 @@ private void ConnectToPresentationSource(PresentationSource presentationSource)
{
if (presentationSource == null)
{
throw new ArgumentNullException("presentationSource");
throw new ArgumentNullException(nameof(presentationSource));
}
_presentationSource = presentationSource;
......
......@@ -50,7 +50,7 @@ public void TextViewCreated(IWpfTextView textView)
{
if (textView == null)
{
throw new ArgumentNullException("textView");
throw new ArgumentNullException(nameof(textView));
}
if (!textView.TextBuffer.GetOption(EditorComponentOnOffOptions.Adornment))
......
......@@ -71,12 +71,12 @@ public async Task<MetadataAsSourceFile> GetGeneratedFileAsync(Project project, I
{
if (project == null)
{
throw new ArgumentNullException("project");
throw new ArgumentNullException(nameof(project));
}
if (symbol == null)
{
throw new ArgumentNullException("symbol");
throw new ArgumentNullException(nameof(symbol));
}
if (symbol.Kind == SymbolKind.Namespace)
......
......@@ -28,7 +28,7 @@ private static Icon ConvertBitmapSourceToIcon(BitmapSource bmpSource)
{
if (bmpSource == null)
{
throw new ArgumentNullException("bmpSource");
throw new ArgumentNullException(nameof(bmpSource));
}
// We shall convert this BitmapSource to an icon. Sadly, there's no direct API to do this. The approach
......
......@@ -23,12 +23,12 @@ internal class NavigateToItemProviderFactory : INavigateToItemProviderFactory
{
if (glyphService == null)
{
throw new ArgumentNullException("glyphService");
throw new ArgumentNullException(nameof(glyphService));
}
if (asyncListeners == null)
{
throw new ArgumentNullException("asyncListeners");
throw new ArgumentNullException(nameof(asyncListeners));
}
_glyphService = glyphService;
......
......@@ -30,12 +30,12 @@ internal partial class NavigateToHighlightReferenceCommandHandler :
{
if (outliningManagerService == null)
{
throw new ArgumentNullException("outliningManagerService");
throw new ArgumentNullException(nameof(outliningManagerService));
}
if (tagAggregatorFactory == null)
{
throw new ArgumentNullException("tagAggregatorFactory");
throw new ArgumentNullException(nameof(tagAggregatorFactory));
}
_outliningManagerService = outliningManagerService;
......
......@@ -110,7 +110,7 @@ protected ITextSnapshotLine GetPreviousNonBlankOrPreprocessorLine()
{
if (Tree == null)
{
throw new ArgumentNullException("syntaxTree");
throw new ArgumentNullException(nameof(Tree));
}
var line = this.LineToBeIndented;
......
......@@ -22,7 +22,7 @@ public SmartIndent(ITextView textView)
{
if (textView == null)
{
throw new ArgumentNullException("textView");
throw new ArgumentNullException(nameof(textView));
}
_textView = textView;
......
......@@ -25,7 +25,7 @@ internal abstract class AbstractAsynchronousBufferTaggerProvider<TTag> :
{
if (subjectBuffer == null)
{
throw new ArgumentNullException("subjectBuffer");
throw new ArgumentNullException(nameof(subjectBuffer));
}
return this.GetOrCreateTagger<T>(null, subjectBuffer);
......
......@@ -42,7 +42,7 @@ public AsynchronousTaggerProvider(IAsynchronousTaggerDataSource<TTag> dataSource
{
if (dataSource == null)
{
throw new ArgumentNullException("dataSource");
throw new ArgumentNullException(nameof(dataSource));
}
_taggerImplementation = new AsynchronousTaggerProviderImpl(asyncListener, notificationService, dataSource);
......
......@@ -626,7 +626,7 @@ public DkmClrValue InstantiateDynamicViewProxy(DkmInspectionContext inspectionCo
{
if (inspectionContext == null)
{
throw new ArgumentNullException("inspectionContext");
throw new ArgumentNullException(nameof(inspectionContext));
}
var module = new DkmClrModuleInstance(
......
......@@ -787,7 +787,7 @@ public override string GetName(SyntaxNode node)
{
if (node == null)
{
throw new ArgumentNullException("node");
throw new ArgumentNullException(nameof(node));
}
switch (node.Kind())
......@@ -861,7 +861,7 @@ public override SyntaxNode SetName(SyntaxNode node, string name)
{
if (node == null)
{
throw new ArgumentNullException("node");
throw new ArgumentNullException(nameof(node));
}
SyntaxToken newIdentifier = SyntaxFactory.Identifier(name);
......
......@@ -205,7 +205,7 @@ public bool CodeMarkerEx(int nTimerID, byte[] aBuff)
// Check the arguments only after checking whether code markers are enabled
// This allows the calling code to pass null value and avoid calculation of data if nothing is to be logged
if (aBuff == null)
throw new ArgumentNullException("aBuff");
throw new ArgumentNullException(nameof(aBuff));
try
{
......@@ -270,7 +270,7 @@ public bool CodeMarkerEx(int nTimerID, string stringData)
// Check the arguments only after checking whether code markers are enabled
// This allows the calling code to pass null value and avoid calculation of data if nothing is to be logged
if (stringData == null)
throw new ArgumentNullException("stringData");
throw new ArgumentNullException(nameof(stringData));
try
{
......@@ -346,7 +346,7 @@ private static bool UsePrivateCodeMarkers(string regRoot, RegistryView registryV
{
if (regRoot == null)
{
throw new ArgumentNullException("regRoot");
throw new ArgumentNullException(nameof(regRoot));
}
// Reads the Performance subkey from the given registry key
......@@ -410,7 +410,7 @@ public bool InitPerformanceDll(int iApp, string strRegRoot, RegistryView registr
if (strRegRoot == null)
{
throw new ArgumentNullException("strRegRoot");
throw new ArgumentNullException(nameof(strRegRoot));
}
this.regroot = strRegRoot;
......
......@@ -36,7 +36,7 @@ protected AbstractEditorFactory(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
throw new ArgumentNullException(nameof(package));
}
_package = package;
......
......@@ -247,12 +247,12 @@ protected override void ApplyAnalyzerReferenceAdded(ProjectId projectId, Analyze
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (analyzerReference == null)
{
throw new ArgumentNullException("analyzerReference");
throw new ArgumentNullException(nameof(analyzerReference));
}
IVisualStudioHostProject hostProject;
......@@ -272,12 +272,12 @@ protected override void ApplyAnalyzerReferenceRemoved(ProjectId projectId, Analy
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (analyzerReference == null)
{
throw new ArgumentNullException("analyzerReference");
throw new ArgumentNullException(nameof(analyzerReference));
}
IVisualStudioHostProject hostProject;
......@@ -308,12 +308,12 @@ protected override void ApplyMetadataReferenceAdded(ProjectId projectId, Metadat
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (metadataReference == null)
{
throw new ArgumentNullException("metadataReference");
throw new ArgumentNullException(nameof(metadataReference));
}
IVisualStudioHostProject hostProject;
......@@ -333,12 +333,12 @@ protected override void ApplyMetadataReferenceRemoved(ProjectId projectId, Metad
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (metadataReference == null)
{
throw new ArgumentNullException("metadataReference");
throw new ArgumentNullException(nameof(metadataReference));
}
IVisualStudioHostProject hostProject;
......@@ -362,12 +362,12 @@ protected override void ApplyProjectReferenceAdded(ProjectId projectId, ProjectR
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (projectReference == null)
{
throw new ArgumentNullException("projectReference");
throw new ArgumentNullException(nameof(projectReference));
}
IVisualStudioHostProject hostProject;
......@@ -388,12 +388,12 @@ protected override void ApplyProjectReferenceRemoved(ProjectId projectId, Projec
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (projectReference == null)
{
throw new ArgumentNullException("projectReference");
throw new ArgumentNullException(nameof(projectReference));
}
IVisualStudioHostProject hostProject;
......@@ -594,7 +594,7 @@ protected void RemoveDocumentCore(DocumentId documentId)
{
if (documentId == null)
{
throw new ArgumentNullException("documentId");
throw new ArgumentNullException(nameof(documentId));
}
var document = this.GetHostDocument(documentId);
......@@ -669,7 +669,7 @@ public void OpenDocumentCore(DocumentId documentId, bool activate = true)
{
if (documentId == null)
{
throw new ArgumentNullException("documentId");
throw new ArgumentNullException(nameof(documentId));
}
var document = this.GetHostDocument(documentId);
......@@ -736,7 +736,7 @@ public void CloseDocumentCore(DocumentId documentId)
{
if (documentId == null)
{
throw new ArgumentNullException("documentId");
throw new ArgumentNullException(nameof(documentId));
}
if (this.IsDocumentOpen(documentId))
......
......@@ -23,12 +23,12 @@ public ProvideAutomationPropertiesAttribute(string category, string page, string
{
if (category == null)
{
throw new ArgumentNullException("category");
throw new ArgumentNullException(nameof(category));
}
if (page == null)
{
throw new ArgumentNullException("page");
throw new ArgumentNullException(nameof(page));
}
this.PackageGuid = Guid.Parse(packageGuid);
......
......@@ -12,12 +12,12 @@ public static string GetMonikerForHierarchyAndItemId(this IVsRunningDocumentTabl
{
if (runningDocTable == null)
{
throw new ArgumentNullException("runningDocTable");
throw new ArgumentNullException(nameof(runningDocTable));
}
if (hierarchy == null)
{
throw new ArgumentNullException("hierarchy");
throw new ArgumentNullException(nameof(hierarchy));
}
// First, get the doc cookie for this
......
......@@ -43,7 +43,7 @@ internal abstract class AbstractContainedLanguage : IDisposable
{
if (project == null)
{
throw new ArgumentNullException("project");
throw new ArgumentNullException(nameof(project));
}
this.Project = project;
......@@ -57,7 +57,7 @@ protected void SetSubjectBuffer(ITextBuffer subjectBuffer)
{
if (subjectBuffer == null)
{
throw new ArgumentNullException("subjectBuffer");
throw new ArgumentNullException(nameof(subjectBuffer));
}
this.SubjectBuffer = subjectBuffer;
......@@ -70,7 +70,7 @@ protected void SetDataBuffer(ITextBuffer dataBuffer)
{
if (dataBuffer == null)
{
throw new ArgumentNullException("dataBuffer");
throw new ArgumentNullException(nameof(dataBuffer));
}
this.DataBuffer = dataBuffer;
......
......@@ -21,12 +21,12 @@ public CodeActionOperation CreateAddMetadataReferenceOperation(ProjectId project
{
if (projectId == null)
{
throw new ArgumentNullException("projectId");
throw new ArgumentNullException(nameof(projectId));
}
if (assemblyIdentity == null)
{
throw new ArgumentNullException("assemblyIdentity");
throw new ArgumentNullException(nameof(assemblyIdentity));
}
return new AddMetadataReferenceOperation(projectId, assemblyIdentity);
......
......@@ -18,12 +18,12 @@ public static async Task<GraphNodeId> CreateNodeIdAsync(ISymbol symbol, Solution
{
if (symbol == null)
{
throw new ArgumentNullException("symbol");
throw new ArgumentNullException(nameof(symbol));
}
if (solution == null)
{
throw new ArgumentNullException("solution");
throw new ArgumentNullException(nameof(solution));
}
switch (symbol.Kind)
......@@ -59,17 +59,17 @@ public static async Task<GraphNode> CreateNodeAsync(this Graph graph, ISymbol sy
{
if (graph == null)
{
throw new ArgumentNullException("graph");
throw new ArgumentNullException(nameof(graph));
}
if (symbol == null)
{
throw new ArgumentNullException("symbol");
throw new ArgumentNullException(nameof(symbol));
}
if (solution == null)
{
throw new ArgumentNullException("solution");
throw new ArgumentNullException(nameof(solution));
}
return await GraphBuilder.GetOrCreateNodeAsync(graph, symbol, solution, cancellationToken).ConfigureAwait(false);
......
......@@ -86,7 +86,7 @@ protected int GetTabSize(ITextSnapshot snapshot)
{
if (snapshot == null)
{
throw new ArgumentNullException("snapshot");
throw new ArgumentNullException(nameof(snapshot));
}
var textBuffer = snapshot.TextBuffer;
......
......@@ -21,7 +21,7 @@ public SyntaxNodeKey(string name, int ordinal)
{
if (name == null)
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
if (ordinal < -1)
......
......@@ -50,7 +50,7 @@ public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId)
{
if (documentId == null)
{
throw new ArgumentNullException("documentId");
throw new ArgumentNullException(nameof(documentId));
}
var project = ProjectTracker.GetProject(documentId.ProjectId);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册