提交 7a105a46 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #14980 from CyrusNajmabadi/dogfooding

Fix function naming.
......@@ -23,18 +23,8 @@ internal abstract class CommandArgs
public CommandArgs(ITextView textView, ITextBuffer subjectBuffer)
{
if (textView == null)
{
throw new ArgumentNullException(nameof(textView));
}
if (subjectBuffer == null)
{
throw new ArgumentNullException(nameof(subjectBuffer));
}
this.TextView = textView;
this.SubjectBuffer = subjectBuffer;
this.TextView = textView ?? throw new ArgumentNullException(nameof(textView));
this.SubjectBuffer = subjectBuffer ?? throw new ArgumentNullException(nameof(subjectBuffer));
}
}
}
}
\ No newline at end of file
......@@ -18,12 +18,7 @@ internal class ExportContentTypeLanguageServiceAttribute : ExportLanguageService
public ExportContentTypeLanguageServiceAttribute(string defaultContentType, string language, string layer = ServiceLayer.Default)
: base(typeof(IContentTypeLanguageService), language, layer)
{
if (defaultContentType == null)
{
throw new ArgumentNullException(nameof(defaultContentType));
}
this.DefaultContentType = defaultContentType;
this.DefaultContentType = defaultContentType ?? throw new ArgumentNullException(nameof(defaultContentType));
}
}
}
......@@ -14,12 +14,7 @@ internal class ExportBraceMatcherAttribute : ExportAttribute
public ExportBraceMatcherAttribute(string language)
: base(typeof(IBraceMatcher))
{
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Language = language;
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -16,18 +16,8 @@ internal class ExportCompletionProviderMef1Attribute : ExportAttribute
public ExportCompletionProviderMef1Attribute(string name, string language)
: base(typeof(CompletionProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
this.Language = language;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -16,12 +16,7 @@ internal class ExportHighlighterAttribute : ExportAttribute
public ExportHighlighterAttribute(string language)
: base(typeof(IHighlighter))
{
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Language = language;
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
}
\ No newline at end of file
......@@ -15,18 +15,8 @@ internal class ExportQuickInfoProviderAttribute : ExportAttribute
public ExportQuickInfoProviderAttribute(string name, string language)
: base(typeof(IQuickInfoProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
this.Language = language;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -32,10 +32,10 @@ public static void Format(this ITextBuffer buffer, TextSpan span, IEnumerable<IF
public static CaretPreservingEditTransaction CreateEditTransaction(
this ITextView view, string description, ITextUndoHistoryRegistry registry, IEditorOperationsFactoryService service)
{
var transaction = new CaretPreservingEditTransaction(description, view, registry, service);
transaction.MergePolicy = AutomaticCodeChangeMergePolicy.Instance;
return transaction;
return new CaretPreservingEditTransaction(description, view, registry, service)
{
MergePolicy = AutomaticCodeChangeMergePolicy.Instance
};
}
public static SyntaxToken FindToken(this ITextSnapshot snapshot, int position, CancellationToken cancellationToken)
......
......@@ -114,12 +114,7 @@ private void OnPresentationSourceChanged(object sender, SourceChangedEventArgs a
private void ConnectToPresentationSource(PresentationSource presentationSource)
{
if (presentationSource == null)
{
throw new ArgumentNullException(nameof(presentationSource));
}
_presentationSource = presentationSource;
_presentationSource = presentationSource ?? throw new ArgumentNullException(nameof(presentationSource));
if (Application.Current != null && Application.Current.MainWindow != null)
{
......
......@@ -34,12 +34,13 @@ public override GraphicsResult GetGraphics(IWpfTextView view, Geometry bounds)
{
Initialize(view);
var border = new Border();
border.BorderBrush = _graphicsTagBrush;
border.BorderThickness = new Thickness(0, 0, 0, bottom: 1);
border.Height = 1;
border.Width = view.ViewportWidth;
var border = new Border()
{
BorderBrush = _graphicsTagBrush,
BorderThickness = new Thickness(0, 0, 0, bottom: 1),
Height = 1,
Width = view.ViewportWidth
};
EventHandler viewportWidthChangedHandler = (s, e) =>
{
border.Width = view.ViewportWidth;
......
......@@ -23,17 +23,12 @@ internal class NavigateToItemProviderFactory : INavigateToItemProviderFactory
[ImportMany] IEnumerable<Lazy<INavigateToHostVersionService, VisualStudioVersionMetadata>> hostServices,
[ImportMany] IEnumerable<Lazy<IAsynchronousOperationListener, FeatureMetadata>> asyncListeners)
{
if (glyphService == null)
{
throw new ArgumentNullException(nameof(glyphService));
}
if (asyncListeners == null)
{
throw new ArgumentNullException(nameof(asyncListeners));
}
_glyphService = glyphService;
_glyphService = glyphService ?? throw new ArgumentNullException(nameof(glyphService));
_hostServices = hostServices;
_asyncListener = new AggregateAsynchronousOperationListener(asyncListeners, FeatureAttribute.NavigateTo);
}
......
......@@ -312,15 +312,19 @@ private void PushSelectedItemsToPresenter(NavigationBarSelectedTypeAndMember sel
if (oldRight != null)
{
newRight = new NavigationBarPresentedItem(oldRight.Text, oldRight.Glyph, oldRight.Spans, oldRight.ChildItems, oldRight.Bolded, oldRight.Grayed || selectedItems.ShowMemberItemGrayed);
newRight.TrackingSpans = oldRight.TrackingSpans;
newRight = new NavigationBarPresentedItem(oldRight.Text, oldRight.Glyph, oldRight.Spans, oldRight.ChildItems, oldRight.Bolded, oldRight.Grayed || selectedItems.ShowMemberItemGrayed)
{
TrackingSpans = oldRight.TrackingSpans
};
listOfRight.Add(newRight);
}
if (oldLeft != null)
{
newLeft = new NavigationBarPresentedItem(oldLeft.Text, oldLeft.Glyph, oldLeft.Spans, listOfRight, oldLeft.Bolded, oldLeft.Grayed || selectedItems.ShowTypeItemGrayed);
newLeft.TrackingSpans = oldLeft.TrackingSpans;
newLeft = new NavigationBarPresentedItem(oldLeft.Text, oldLeft.Glyph, oldLeft.Spans, listOfRight, oldLeft.Bolded, oldLeft.Grayed || selectedItems.ShowTypeItemGrayed)
{
TrackingSpans = oldLeft.TrackingSpans
};
listOfLeft.Add(newLeft);
}
......
......@@ -29,18 +29,8 @@ internal partial class NavigateToHighlightReferenceCommandHandler :
IOutliningManagerService outliningManagerService,
IViewTagAggregatorFactoryService tagAggregatorFactory)
{
if (outliningManagerService == null)
{
throw new ArgumentNullException(nameof(outliningManagerService));
}
if (tagAggregatorFactory == null)
{
throw new ArgumentNullException(nameof(tagAggregatorFactory));
}
_outliningManagerService = outliningManagerService;
_tagAggregatorFactory = tagAggregatorFactory;
_outliningManagerService = outliningManagerService ?? throw new ArgumentNullException(nameof(outliningManagerService));
_tagAggregatorFactory = tagAggregatorFactory ?? throw new ArgumentNullException(nameof(tagAggregatorFactory));
}
public CommandState GetCommandState(NavigateToHighlightedReferenceCommandArgs args, Func<CommandState> nextHandler)
......
......@@ -18,12 +18,7 @@ internal partial class SmartIndent : ISmartIndent
public SmartIndent(ITextView textView)
{
if (textView == null)
{
throw new ArgumentNullException(nameof(textView));
}
_textView = textView;
_textView = textView ?? throw new ArgumentNullException(nameof(textView));
}
public int? GetDesiredIndentation(ITextSnapshotLine line)
......
......@@ -15,11 +15,8 @@ internal class SynchronizationContextTaskScheduler : TaskScheduler
internal SynchronizationContextTaskScheduler(SynchronizationContext synchronizationContext)
{
if (synchronizationContext == null)
throw new ArgumentNullException(nameof(synchronizationContext));
_postCallback = new SendOrPostCallback(PostCallback);
_synchronizationContext = synchronizationContext;
_synchronizationContext = synchronizationContext ?? throw new ArgumentNullException(nameof(synchronizationContext));
}
public override Int32 MaximumConcurrencyLevel
......
......@@ -83,12 +83,7 @@ public void AddTag(ITagSpan<TTag> tag)
/// </summary>
public void SetSpansTagged(IEnumerable<DocumentSnapshotSpan> spansTagged)
{
if (spansTagged == null)
{
throw new ArgumentNullException(nameof(spansTagged));
}
this._spansTagged = spansTagged;
this._spansTagged = spansTagged ?? throw new ArgumentNullException(nameof(spansTagged));
}
public IEnumerable<ITagSpan<TTag>> GetExistingTags(SnapshotSpan span)
......
......@@ -27,23 +27,13 @@ internal class ExportSuppressionFixProviderAttribute : ExportAttribute
params string[] languages)
: base(typeof(ISuppressionFixProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (languages == null)
{
throw new ArgumentNullException(nameof(languages));
}
if (languages.Length == 0)
{
throw new ArgumentException("languages");
}
this.Name = name;
this.Languages = languages;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Languages = languages ?? throw new ArgumentNullException(nameof(languages));
}
}
}
......@@ -21,12 +21,7 @@ public class DocumentNavigationOperation : CodeActionOperation
public DocumentNavigationOperation(DocumentId documentId, int position = 0)
{
if (documentId == null)
{
throw new ArgumentNullException(nameof(documentId));
}
_documentId = documentId;
_documentId = documentId ?? throw new ArgumentNullException(nameof(documentId));
_position = position;
}
......
......@@ -32,18 +32,8 @@ public struct TaggedText
/// <param name="text">The actual text to be displayed.</param>
public TaggedText(string tag, string text)
{
if (tag == null)
{
throw new ArgumentNullException(nameof(tag));
}
if (text == null)
{
throw new ArgumentNullException(nameof(text));
}
Tag = tag;
Text = text;
Tag = tag ?? throw new ArgumentNullException(nameof(tag));
Text = text ?? throw new ArgumentNullException(nameof(text));
}
public override string ToString()
......
......@@ -85,27 +85,12 @@ internal IReadOnlyList<CompletionItem> Items
OptionSet options,
CancellationToken cancellationToken)
{
if (provider == null)
{
throw new ArgumentNullException(nameof(provider));
}
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
if (options == null)
{
throw new ArgumentException(nameof(options));
}
this.Provider = provider;
this.Document = document;
this.Provider = provider ?? throw new ArgumentNullException(nameof(provider));
this.Document = document ?? throw new ArgumentNullException(nameof(document));
this.Position = position;
this.CompletionListSpan = defaultSpan;
this.Trigger = trigger;
this.Options = options;
this.Options = options ?? throw new ArgumentException(nameof(options));
this.CancellationToken = cancellationToken;
_items = new List<CompletionItem>();
}
......
......@@ -20,18 +20,8 @@ public sealed class ExportCompletionProviderAttribute : ExportAttribute
public ExportCompletionProviderAttribute(string name, string language)
: base(typeof(CompletionProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
this.Language = language;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -304,14 +304,15 @@ internal XElement CreateXElement()
internal static NamingStyle FromXElement(XElement namingStyleElement)
{
var result = new NamingStyle();
result.ID = Guid.Parse(namingStyleElement.Attribute(nameof(ID)).Value);
result.Name = namingStyleElement.Attribute(nameof(Name)).Value;
result.Prefix = namingStyleElement.Attribute(nameof(Prefix)).Value;
result.Suffix = namingStyleElement.Attribute(nameof(Suffix)).Value;
result.WordSeparator = namingStyleElement.Attribute(nameof(WordSeparator)).Value;
result.CapitalizationScheme = (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value);
return result;
return new NamingStyle()
{
ID = Guid.Parse(namingStyleElement.Attribute(nameof(ID)).Value),
Name = namingStyleElement.Attribute(nameof(Name)).Value,
Prefix = namingStyleElement.Attribute(nameof(Prefix)).Value,
Suffix = namingStyleElement.Attribute(nameof(Suffix)).Value,
WordSeparator = namingStyleElement.Attribute(nameof(WordSeparator)).Value,
CapitalizationScheme = (Capitalization)Enum.Parse(typeof(Capitalization), namingStyleElement.Attribute(nameof(CapitalizationScheme)).Value)
};
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Xml.Linq;
namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles
......@@ -34,11 +31,12 @@ internal XElement CreateXElement()
internal static SerializableNamingRule FromXElement(XElement namingRuleElement)
{
var result = new SerializableNamingRule();
result.EnforcementLevel = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel)).Value);
result.NamingStyleID = Guid.Parse(namingRuleElement.Attribute(nameof(NamingStyleID)).Value);
result.SymbolSpecificationID = Guid.Parse(namingRuleElement.Attribute(nameof(SymbolSpecificationID)).Value);
return result;
return new SerializableNamingRule()
{
EnforcementLevel = (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), namingRuleElement.Attribute(nameof(EnforcementLevel)).Value),
NamingStyleID = Guid.Parse(namingRuleElement.Attribute(nameof(NamingStyleID)).Value),
SymbolSpecificationID = Guid.Parse(namingRuleElement.Attribute(nameof(SymbolSpecificationID)).Value)
};
}
}
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ internal class SerializableNamingStylePreferencesInfo
public List<SymbolSpecification> SymbolSpecifications;
public List<NamingStyle> NamingStyles;
public List<SerializableNamingRule> NamingRules;
private readonly static int _serializationVersion = 3;
private readonly static int s_serializationVersion = 3;
internal SerializableNamingStylePreferencesInfo()
{
......@@ -47,7 +47,7 @@ public NamingStylePreferencesInfo GetPreferencesInfo()
internal XElement CreateXElement()
{
return new XElement("NamingPreferencesInfo",
new XAttribute("SerializationVersion", _serializationVersion),
new XAttribute("SerializationVersion", s_serializationVersion),
CreateSymbolSpecificationListXElement(),
CreateNamingStyleListXElement(),
CreateNamingRuleTreeXElement());
......@@ -94,7 +94,7 @@ internal static SerializableNamingStylePreferencesInfo FromXElement(XElement nam
var namingPreferencesInfo = new SerializableNamingStylePreferencesInfo();
var serializationVersion = int.Parse(namingPreferencesInfoElement.Attribute("SerializationVersion").Value);
if (serializationVersion != _serializationVersion)
if (serializationVersion != s_serializationVersion)
{
namingPreferencesInfoElement = XElement.Parse(SimplificationOptions.NamingPreferences.DefaultValue);
}
......
......@@ -133,10 +133,11 @@ private XElement CreateModifiersXElement()
internal static SymbolSpecification FromXElement(XElement symbolSpecificationElement)
{
var result = new SymbolSpecification();
result.ID = Guid.Parse(symbolSpecificationElement.Attribute(nameof(ID)).Value);
result.Name = symbolSpecificationElement.Attribute(nameof(Name)).Value;
var result = new SymbolSpecification()
{
ID = Guid.Parse(symbolSpecificationElement.Attribute(nameof(ID)).Value),
Name = symbolSpecificationElement.Attribute(nameof(Name)).Value
};
result.PopulateSymbolKindListFromXElement(symbolSpecificationElement.Element(nameof(ApplicableSymbolKindList)));
result.PopulateAccessibilityListFromXElement(symbolSpecificationElement.Element(nameof(ApplicableAccessibilityList)));
result.PopulateModifierListFromXElement(symbolSpecificationElement.Element(nameof(RequiredModifierList)));
......
......@@ -19,18 +19,18 @@ internal abstract partial class AbstractNavigateToSearchService
public static Task<ImmutableArray<INavigateToSearchResult>> SearchProjectInCurrentProcessAsync(
Project project, string searchPattern, CancellationToken cancellationToken)
{
return FindNavigableDeclaredSymbolInfos(
return FindNavigableDeclaredSymbolInfosAsync(
project, searchDocument: null, pattern: searchPattern, cancellationToken: cancellationToken);
}
public static Task<ImmutableArray<INavigateToSearchResult>> SearchDocumentInCurrentProcessAsync(
Document document, string searchPattern, CancellationToken cancellationToken)
{
return FindNavigableDeclaredSymbolInfos(
return FindNavigableDeclaredSymbolInfosAsync(
document.Project, document, searchPattern, cancellationToken);
}
private static async Task<ImmutableArray<INavigateToSearchResult>> FindNavigableDeclaredSymbolInfos(
private static async Task<ImmutableArray<INavigateToSearchResult>> FindNavigableDeclaredSymbolInfosAsync(
Project project, Document searchDocument, string pattern, CancellationToken cancellationToken)
{
var containsDots = pattern.IndexOf('.') >= 0;
......
......@@ -15,18 +15,8 @@ internal class ExportSignatureHelpProviderAttribute : ExportAttribute
public ExportSignatureHelpProviderAttribute(string name, string language)
: base(typeof(ISignatureHelpProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
this.Language = language;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -15,18 +15,8 @@ internal class ExportPerLanguageIncrementalAnalyzerProviderAttribute : ExportAtt
public ExportPerLanguageIncrementalAnalyzerProviderAttribute(string name, string language)
: base(typeof(IPerLanguageIncrementalAnalyzerProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
this.Language = language;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -36,12 +36,7 @@ internal abstract partial class AbstractEditorFactory : IVsEditorFactory, IVsEdi
protected AbstractEditorFactory(Package package)
{
if (package == null)
{
throw new ArgumentNullException(nameof(package));
}
_package = package;
_package = package ?? throw new ArgumentNullException(nameof(package));
_componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel));
_editorAdaptersFactoryService = _componentModel.GetService<IVsEditorAdaptersFactoryService>();
......
......@@ -21,19 +21,9 @@ internal sealed class ProvideAutomationPropertiesAttribute : RegistrationAttribu
public ProvideAutomationPropertiesAttribute(string category, string page, string packageGuid, int profileNodeLabelId, int profileNodeDescriptionId, string resourcePackageGuid = null)
{
if (category == null)
{
throw new ArgumentNullException(nameof(category));
}
if (page == null)
{
throw new ArgumentNullException(nameof(page));
}
this.PackageGuid = Guid.Parse(packageGuid);
this.Category = category;
this.Page = page;
this.Category = category ?? throw new ArgumentNullException(nameof(category));
this.Page = page ?? throw new ArgumentNullException(nameof(page));
this.ProfileNodeLabelId = profileNodeLabelId;
this.ProfileNodeDescriptionId = profileNodeDescriptionId;
......
......@@ -40,12 +40,7 @@ internal abstract class AbstractContainedLanguage : IDisposable
public AbstractContainedLanguage(
AbstractProject project)
{
if (project == null)
{
throw new ArgumentNullException(nameof(project));
}
this.Project = project;
this.Project = project ?? throw new ArgumentNullException(nameof(project));
}
/// <summary>
......@@ -54,12 +49,7 @@ internal abstract class AbstractContainedLanguage : IDisposable
/// <param name="subjectBuffer"></param>
protected void SetSubjectBuffer(ITextBuffer subjectBuffer)
{
if (subjectBuffer == null)
{
throw new ArgumentNullException(nameof(subjectBuffer));
}
this.SubjectBuffer = subjectBuffer;
this.SubjectBuffer = subjectBuffer ?? throw new ArgumentNullException(nameof(subjectBuffer));
}
/// <summary>
......@@ -67,12 +57,7 @@ protected void SetSubjectBuffer(ITextBuffer subjectBuffer)
/// </summary>
protected void SetDataBuffer(ITextBuffer dataBuffer)
{
if (dataBuffer == null)
{
throw new ArgumentNullException(nameof(dataBuffer));
}
this.DataBuffer = dataBuffer;
this.DataBuffer = dataBuffer ?? throw new ArgumentNullException(nameof(dataBuffer));
}
public abstract void Dispose();
......
......@@ -28,12 +28,7 @@ public sealed class ApplyChangesOperation : CodeActionOperation
public ApplyChangesOperation(Solution changedSolution)
{
if (changedSolution == null)
{
throw new ArgumentNullException(nameof(changedSolution));
}
ChangedSolution = changedSolution;
ChangedSolution = changedSolution ?? throw new ArgumentNullException(nameof(changedSolution));
}
internal override bool ApplyDuringTests => true;
......
......@@ -15,12 +15,7 @@ public sealed class OpenDocumentOperation : CodeActionOperation
public OpenDocumentOperation(DocumentId documentId, bool activateIfAlreadyOpen = false)
{
if (documentId == null)
{
throw new ArgumentNullException(nameof(documentId));
}
_documentId = documentId;
_documentId = documentId ?? throw new ArgumentNullException(nameof(documentId));
_activate = activateIfAlreadyOpen;
}
......
......@@ -19,18 +19,13 @@ internal class ExportCodeCleanupProvider : ExportAttribute
public ExportCodeCleanupProvider(string name, params string[] languages)
: base(typeof(ICodeCleanupProvider))
{
if (languages == null)
{
throw new ArgumentNullException(nameof(languages));
}
if (languages.Length == 0)
{
throw new ArgumentException("languages");
}
this.Name = name;
this.Languages = languages;
this.Languages = languages ?? throw new ArgumentNullException(nameof(languages));
}
}
}
......@@ -32,11 +32,6 @@ public sealed class ExportCodeFixProviderAttribute : ExportAttribute
params string[] additionalLanguages)
: base(typeof(CodeFixProvider))
{
if (firstLanguage == null)
{
throw new ArgumentNullException(nameof(firstLanguage));
}
if (additionalLanguages == null)
{
throw new ArgumentNullException(nameof(additionalLanguages));
......@@ -45,7 +40,7 @@ public sealed class ExportCodeFixProviderAttribute : ExportAttribute
this.Name = null;
string[] languages = new string[additionalLanguages.Length + 1];
languages[0] = firstLanguage;
languages[0] = firstLanguage ?? throw new ArgumentNullException(nameof(firstLanguage));
for (int index = 0; index < additionalLanguages.Length; index++)
{
languages[index + 1] = additionalLanguages[index];
......
......@@ -65,12 +65,6 @@ internal partial class FixAllState
FixAllContext.DiagnosticProvider fixAllDiagnosticProvider)
{
Contract.ThrowIfNull(project);
if (codeFixProvider == null)
{
throw new ArgumentNullException(nameof(codeFixProvider));
}
if (diagnosticIds == null)
{
throw new ArgumentNullException(nameof(diagnosticIds));
......@@ -81,19 +75,14 @@ internal partial class FixAllState
throw new ArgumentException(WorkspacesResources.Supplied_diagnostic_cannot_be_null, nameof(diagnosticIds));
}
if (fixAllDiagnosticProvider == null)
{
throw new ArgumentNullException(nameof(fixAllDiagnosticProvider));
}
this.FixAllProvider = fixAllProvider;
this.Document = document;
this.Project = project;
this.CodeFixProvider = codeFixProvider;
this.CodeFixProvider = codeFixProvider ?? throw new ArgumentNullException(nameof(codeFixProvider));
this.Scope = scope;
this.CodeActionEquivalenceKey = codeActionEquivalenceKey;
this.DiagnosticIds = ImmutableHashSet.CreateRange(diagnosticIds);
this.DiagnosticProvider = fixAllDiagnosticProvider;
this.DiagnosticProvider = fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider));
}
internal bool IsFixMultiple => this.DiagnosticProvider.IsFixMultiple;
......
......@@ -38,19 +38,9 @@ public struct CodeRefactoringContext
Action<CodeAction> registerRefactoring,
CancellationToken cancellationToken)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
if (registerRefactoring == null)
{
throw new ArgumentNullException(nameof(registerRefactoring));
}
Document = document;
Document = document ?? throw new ArgumentNullException(nameof(document));
Span = span;
_registerRefactoring = registerRefactoring;
_registerRefactoring = registerRefactoring ?? throw new ArgumentNullException(nameof(registerRefactoring));
CancellationToken = cancellationToken;
}
......
......@@ -30,11 +30,6 @@ public sealed class ExportCodeRefactoringProviderAttribute : ExportAttribute
public ExportCodeRefactoringProviderAttribute(string firstLanguage, params string[] additionalLanguages)
: base(typeof(CodeRefactoringProvider))
{
if (firstLanguage == null)
{
throw new ArgumentNullException(nameof(firstLanguage));
}
if (additionalLanguages == null)
{
throw new ArgumentNullException(nameof(additionalLanguages));
......@@ -43,7 +38,7 @@ public ExportCodeRefactoringProviderAttribute(string firstLanguage, params strin
this.Name = null;
string[] languages = new string[additionalLanguages.Length + 1];
languages[0] = firstLanguage;
languages[0] = firstLanguage ?? throw new ArgumentNullException(nameof(firstLanguage));
for (int index = 0; index < additionalLanguages.Length; index++)
{
languages[index + 1] = additionalLanguages[index];
......
......@@ -20,17 +20,12 @@ public class SyntaxEditor
/// </summary>
public SyntaxEditor(SyntaxNode root, Workspace workspace)
{
if (root == null)
{
throw new ArgumentNullException(nameof(root));
}
if (workspace == null)
{
throw new ArgumentNullException(nameof(workspace));
}
_root = root;
_root = root ?? throw new ArgumentNullException(nameof(root));
_generator = SyntaxGenerator.GetGenerator(workspace, root.Language);
_changes = new List<Change>();
}
......
......@@ -54,12 +54,7 @@ internal class SearchQuery
private SearchQuery(string name, SearchKind kind)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
Name = name;
Name = name ?? throw new ArgumentNullException(nameof(name));
Kind = kind;
switch (kind)
......@@ -83,13 +78,8 @@ private SearchQuery(string name, SearchKind kind)
private SearchQuery(Func<string, bool> predicate)
{
if (predicate == null)
{
throw new ArgumentNullException(nameof(predicate));
}
Kind = SearchKind.Custom;
_predicate = predicate;
_predicate = predicate ?? throw new ArgumentNullException(nameof(predicate));
}
public static SearchQuery Create(string name, bool ignoreCase)
......
......@@ -32,19 +32,9 @@ internal partial class SyntaxTreeIdentifierInfo : AbstractSyntaxTreeInfo
BloomFilter escapedIdentifierFilter) :
base(version)
{
if (identifierFilter == null)
{
throw new ArgumentNullException(nameof(identifierFilter));
}
if (escapedIdentifierFilter == null)
{
throw new ArgumentNullException(nameof(escapedIdentifierFilter));
}
_version = version;
_identifierFilter = identifierFilter;
_escapedIdentifierFilter = escapedIdentifierFilter;
_identifierFilter = identifierFilter ?? throw new ArgumentNullException(nameof(identifierFilter));
_escapedIdentifierFilter = escapedIdentifierFilter ?? throw new ArgumentNullException(nameof(escapedIdentifierFilter));
}
/// <summary>
......
......@@ -18,13 +18,8 @@ internal class ExportFormattingRule : ExportAttribute
public ExportFormattingRule(string name, string language)
: base(typeof(IFormattingRule))
{
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.Name = name;
this.Language = language;
this.Language = language ?? throw new ArgumentNullException(nameof(language));
}
}
}
......@@ -12,11 +12,6 @@ public struct OptionKey : IEquatable<OptionKey>
public OptionKey(IOption option, string language = null)
{
if (option == null)
{
throw new ArgumentNullException(nameof(option));
}
if (language != null && !option.IsPerLanguage)
{
throw new ArgumentException(WorkspacesResources.A_language_name_cannot_be_specified_for_this_option);
......@@ -26,7 +21,7 @@ public OptionKey(IOption option, string language = null)
throw new ArgumentNullException(WorkspacesResources.A_language_name_must_be_specified_for_this_option);
}
this.Option = option;
this.Option = option ?? throw new ArgumentNullException(nameof(option));
this.Language = language;
}
......
......@@ -47,12 +47,7 @@ public BloomFilter(double falsePositiveProbability, bool isCaseSensitive, IColle
private BloomFilter(BitArray bitArray, int hashFunctionCount, bool isCaseSensitive)
{
if (bitArray == null)
{
throw new ArgumentNullException(nameof(bitArray));
}
_bitArray = bitArray;
_bitArray = bitArray ?? throw new ArgumentNullException(nameof(bitArray));
_hashFunctionCount = hashFunctionCount;
_isCaseSensitive = isCaseSensitive;
}
......
......@@ -16,13 +16,9 @@ internal class ExportIncrementalAnalyzerProviderAttribute : ExportAttribute
public ExportIncrementalAnalyzerProviderAttribute(params string[] workspaceKinds)
: base(typeof(IIncrementalAnalyzerProvider))
{
if (workspaceKinds == null)
{
throw new ArgumentNullException(nameof(workspaceKinds));
}
// TODO: this will be removed once closed side changes are in.
this.WorkspaceKinds = workspaceKinds;
this.WorkspaceKinds = workspaceKinds ?? throw new ArgumentNullException(nameof(workspaceKinds));
this.Name = "Unknown";
this.HighPriorityForActiveFile = false;
}
......@@ -30,13 +26,8 @@ public ExportIncrementalAnalyzerProviderAttribute(params string[] workspaceKinds
public ExportIncrementalAnalyzerProviderAttribute(string name, string[] workspaceKinds)
: base(typeof(IIncrementalAnalyzerProvider))
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
this.WorkspaceKinds = workspaceKinds;
this.Name = name;
this.Name = name ?? throw new ArgumentNullException(nameof(name));
this.HighPriorityForActiveFile = false;
}
......
......@@ -84,12 +84,7 @@ internal partial struct SymbolKey
public SymbolKey(string symbolKeyData)
{
if (symbolKeyData == null)
{
throw new ArgumentNullException();
}
_symbolKeyData = symbolKeyData;
_symbolKeyData = symbolKeyData ?? throw new ArgumentNullException();
}
public static IEqualityComparer<SymbolKey> GetComparer(bool ignoreCase, bool ignoreAssemblyKeys)
......
......@@ -48,12 +48,7 @@ internal class EditDistance : IDisposable
public EditDistance(string text)
{
if (text == null)
{
throw new ArgumentNullException(nameof(text));
}
_source = text;
_source = text ?? throw new ArgumentNullException(nameof(text));
_sourceLowerCaseCharacters = ConvertToLowercaseArray(text);
}
......
......@@ -108,12 +108,7 @@ public CacheResult(string candidate, bool areSimilar, double similarityWeight)
public WordSimilarityChecker(string text, bool substringsAreSimilar)
{
if (text == null)
{
throw new ArgumentNullException(nameof(text));
}
_source = text;
_source = text ?? throw new ArgumentNullException(nameof(text));
_threshold = GetThreshold(_source);
_editDistance = new EditDistance(text);
_substringsAreSimilar = substringsAreSimilar;
......
......@@ -41,13 +41,8 @@ public ExportLanguageServiceAttribute(Type type, string language, string layer =
throw new ArgumentNullException(nameof(type));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.ServiceType = type.AssemblyQualifiedName;
this.Language = language;
this.Language = language ?? throw new ArgumentNullException(nameof(language));
this.Layer = layer;
}
}
......
......@@ -41,13 +41,8 @@ public ExportLanguageServiceFactoryAttribute(Type type, string language, string
throw new ArgumentNullException(nameof(type));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
this.ServiceType = type.AssemblyQualifiedName;
this.Language = language;
this.Language = language ?? throw new ArgumentNullException(nameof(language));
this.Layer = layer;
}
}
......
......@@ -35,13 +35,8 @@ public ExportWorkspaceServiceAttribute(Type serviceType, string layer = ServiceL
throw new ArgumentNullException(nameof(serviceType));
}
if (layer == null)
{
throw new ArgumentNullException(nameof(layer));
}
this.ServiceType = serviceType.AssemblyQualifiedName;
this.Layer = layer;
this.Layer = layer ?? throw new ArgumentNullException(nameof(layer));
}
}
}
......@@ -35,13 +35,8 @@ public ExportWorkspaceServiceFactoryAttribute(Type serviceType, string layer = S
throw new ArgumentNullException(nameof(serviceType));
}
if (layer == null)
{
throw new ArgumentNullException(nameof(layer));
}
this.ServiceType = serviceType.AssemblyQualifiedName;
this.Layer = layer;
this.Layer = layer ?? throw new ArgumentNullException(nameof(layer));
}
}
}
......@@ -19,12 +19,7 @@ internal class MetadataReferenceCache
public MetadataReferenceCache(Func<string, MetadataReferenceProperties, MetadataReference> createReference)
{
if (createReference == null)
{
throw new ArgumentNullException(nameof(createReference));
}
_createReference = createReference;
_createReference = createReference ?? throw new ArgumentNullException(nameof(createReference));
}
public MetadataReference GetReference(string path, MetadataReferenceProperties properties)
......
......@@ -18,12 +18,7 @@ internal sealed class AdditionalTextDocument : AdditionalText
/// </summary>
public AdditionalTextDocument(TextDocumentState document)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
_document = document;
_document = document ?? throw new ArgumentNullException(nameof(document));
}
/// <summary>
......
......@@ -167,18 +167,8 @@ internal class DocumentAttributes : IChecksummedObject, IObjectWritable
string filePath,
bool isGenerated)
{
if (id == null)
{
throw new ArgumentNullException(nameof(id));
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
Id = id;
Name = name;
Id = id ?? throw new ArgumentNullException(nameof(id));
Name = name ?? throw new ArgumentNullException(nameof(name));
Folders = folders.ToImmutableReadOnlyListOrEmpty();
SourceCodeKind = sourceCodeKind;
FilePath = filePath;
......
......@@ -377,30 +377,10 @@ internal class ProjectAttributes : IChecksummedObject, IObjectWritable
bool isSubmission,
bool hasAllInformation)
{
if (id == null)
{
throw new ArgumentNullException(nameof(id));
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (language == null)
{
throw new ArgumentNullException(nameof(language));
}
if (assemblyName == null)
{
throw new ArgumentNullException(nameof(assemblyName));
}
Id = id;
Name = name;
Language = language;
AssemblyName = assemblyName;
Id = id ?? throw new ArgumentNullException(nameof(id));
Name = name ?? throw new ArgumentNullException(nameof(name));
Language = language ?? throw new ArgumentNullException(nameof(language));
AssemblyName = assemblyName ?? throw new ArgumentNullException(nameof(assemblyName));
Version = version;
FilePath = filePath;
......
......@@ -106,12 +106,7 @@ internal class SolutionAttributes : IChecksummedObject, IObjectWritable
public SolutionAttributes(SolutionId id, VersionStamp version, string filePath)
{
if (id == null)
{
throw new ArgumentNullException(nameof(id));
}
Id = id;
Id = id ?? throw new ArgumentNullException(nameof(id));
Version = version;
FilePath = filePath;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册