提交 76e58709 编写于 作者: C Cyrus Najmabadi

Use compound assignment

上级 a79ccc93
......@@ -79,7 +79,7 @@ public OrderPreservingMultiDictionary()
private void EnsureDictionary()
{
_dictionary = _dictionary ?? PooledDictionary<K, ValueSet>.GetInstance();
_dictionary ??= PooledDictionary<K, ValueSet>.GetInstance();
}
public bool IsEmpty => _dictionary == null;
......
......@@ -69,7 +69,7 @@ private Assembly LoadFromPathUncheckedCore(string fullPath, AssemblyIdentity ide
}
else
{
identity = identity ?? GetOrAddAssemblyIdentity(fullPath);
identity ??= GetOrAddAssemblyIdentity(fullPath);
if (identity != null && _loadedAssembliesByIdentity.TryGetValue(identity, out existingAssembly))
{
loadedAssembly = existingAssembly;
......
......@@ -46,7 +46,7 @@ public static string TrimTrailingSeparators(string s)
int lastSeparator = s.Length;
while (lastSeparator > 0 && IsDirectorySeparator(s[lastSeparator - 1]))
{
lastSeparator = lastSeparator - 1;
lastSeparator -= 1;
}
if (lastSeparator != s.Length)
......
......@@ -15,7 +15,7 @@ public static int CountBits(uint v)
{
unchecked
{
v = v - ((v >> 1) & 0x55555555u);
v -= ((v >> 1) & 0x55555555u);
v = (v & 0x33333333u) + ((v >> 2) & 0x33333333u);
return (int)((v + (v >> 4) & 0xF0F0F0Fu) * 0x1010101u) >> 24;
}
......
......@@ -44,7 +44,7 @@ protected AbstractAddImportsService()
private static ImmutableArray<SyntaxNode> GetAllContainers(SyntaxNode root, SyntaxNode contextLocation)
{
contextLocation = contextLocation ?? root;
contextLocation ??= root;
var applicableContainer = GetFirstApplicableContainer(contextLocation);
return applicableContainer.GetAncestorsOrThis<SyntaxNode>().ToImmutableArray();
......@@ -79,7 +79,7 @@ private static ImmutableArray<SyntaxNode> GetAllContainers(SyntaxNode root, Synt
public SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode contextLocation, SyntaxNode import)
{
contextLocation = contextLocation ?? root;
contextLocation ??= root;
GetContainers(root, contextLocation,
out var externContainer, out var usingContainer, out var staticUsingContainer, out var aliasContainer);
......@@ -110,7 +110,7 @@ public SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode contextLocation
IEnumerable<SyntaxNode> newImports,
bool placeSystemNamespaceFirst)
{
contextLocation = contextLocation ?? root;
contextLocation ??= root;
var globalImports = GetGlobalImports(compilation);
var containers = GetAllContainers(root, contextLocation);
......
......@@ -176,7 +176,7 @@ protected static T Cast<T>(object value)
IEnumerable<ISymbol> members,
CancellationToken cancellationToken)
{
options = options ?? CodeGenerationOptions.Default;
options ??= CodeGenerationOptions.Default;
var (destinationDeclaration, availableIndices) =
await this.FindMostRelevantDeclarationAsync(solution, destination, options, cancellationToken).ConfigureAwait(false);
......@@ -207,7 +207,7 @@ protected static T Cast<T>(object value)
public async Task<Document> AddImportsAsync(Document document, CodeGenerationOptions options, CancellationToken cancellationToken)
{
options = options ?? CodeGenerationOptions.Default;
options ??= CodeGenerationOptions.Default;
var adder = this.CreateImportsAdder(document);
var newDocument = await adder.AddAsync(options.PlaceSystemNamespaceFirst, options, cancellationToken).ConfigureAwait(false);
return newDocument;
......
......@@ -179,7 +179,7 @@ class NestedType
// Then, prefer a declaration from the same file.
declaration = await SelectFirstOrDefaultAsync(declarations.Where(r => r.SyntaxTree == locationOpt.SourceTree), node => true, cancellationToken).ConfigureAwait(false);
fallbackDeclaration = fallbackDeclaration ?? declaration;
fallbackDeclaration ??= declaration;
if (CanAddTo(declaration, solution, cancellationToken, out availableIndices))
{
return (declaration, availableIndices);
......
......@@ -57,7 +57,7 @@ protected AbstractImportsAdder(Document document)
cancellationToken.ThrowIfCancellationRequested();
if (!IsBuiltIn(namedType))
{
namespaceScope = namespaceScope ?? this.GetInnermostNamespaceScope(annotatedNode);
namespaceScope ??= this.GetInnermostNamespaceScope(annotatedNode);
var referencedDefinitions = namespaceScopeToReferencedDefinitions.GetOrAdd(
namespaceScope, createSet);
referencedDefinitions.Add(namedType);
......
......@@ -34,7 +34,7 @@ public static bool TryParseBoolEditorConfigCodeStyleOption(string arg, out CodeS
// 'true' must always be provided with a notification option.
if (isEnabled == false)
{
notificationOpt = notificationOpt ?? NotificationOption.Silent;
notificationOpt ??= NotificationOption.Silent;
option = new CodeStyleOption<bool>(false, notificationOpt);
return true;
}
......
......@@ -274,7 +274,7 @@ private static CodeStyleOption<AccessibilityModifiersRequired> ParseAccessibilit
if (value == "never")
{
// If they provide 'never', they don't need a notification level.
notificationOpt = notificationOpt ?? NotificationOption.Silent;
notificationOpt ??= NotificationOption.Silent;
}
if (notificationOpt != null)
......
......@@ -69,7 +69,7 @@ internal struct DiagnosticAnalysisResult
IsEmpty = false;
// do after all fields are assigned.
DocumentIds = DocumentIds ?? CreateDocumentIds();
DocumentIds ??= CreateDocumentIds();
IsEmpty = DocumentIds.IsEmpty && _others.IsEmpty;
}
......
......@@ -83,7 +83,7 @@ public void AddExternalSemanticDiagnostics(DocumentId documentId, IEnumerable<Di
else
{
// non local diagnostics without location
_lazyOthers = _lazyOthers ?? new List<DiagnosticData>();
_lazyOthers ??= new List<DiagnosticData>();
_lazyOthers.Add(DiagnosticData.Create(Project, diagnostic));
}
......@@ -91,7 +91,7 @@ public void AddExternalSemanticDiagnostics(DocumentId documentId, IEnumerable<Di
}
case LocationKind.None:
{
_lazyOthers = _lazyOthers ?? new List<DiagnosticData>();
_lazyOthers ??= new List<DiagnosticData>();
_lazyOthers.Add(DiagnosticData.Create(Project, diagnostic));
break;
}
......@@ -123,7 +123,7 @@ private void AppendDiagnostics(ref Dictionary<DocumentId, List<DiagnosticData>>
return;
}
map = map ?? new Dictionary<DocumentId, List<DiagnosticData>>();
map ??= new Dictionary<DocumentId, List<DiagnosticData>>();
map.GetOrAdd(documentOpt.Id, _ => new List<DiagnosticData>()).Add(DiagnosticData.Create(documentOpt, diagnostic));
AddDocumentToSet(documentOpt);
......@@ -163,7 +163,7 @@ public void AddCompilationDiagnostics(IEnumerable<Diagnostic> diagnostics)
}
case LocationKind.None:
{
_lazyOthers = _lazyOthers ?? new List<DiagnosticData>();
_lazyOthers ??= new List<DiagnosticData>();
_lazyOthers.Add(DiagnosticData.Create(Project, diagnostic));
break;
}
......@@ -182,7 +182,7 @@ public void AddCompilationDiagnostics(IEnumerable<Diagnostic> diagnostics)
else
{
// non local diagnostics without location
_lazyOthers = _lazyOthers ?? new List<DiagnosticData>();
_lazyOthers ??= new List<DiagnosticData>();
_lazyOthers.Add(DiagnosticData.Create(Project, diagnostic));
}
......@@ -205,7 +205,7 @@ public void AddCompilationDiagnostics(IEnumerable<Diagnostic> diagnostics)
private void AddDocumentToSet(Document document)
{
_lazySet = _lazySet ?? new HashSet<DocumentId>();
_lazySet ??= new HashSet<DocumentId>();
_lazySet.Add(document.Id);
}
......
......@@ -22,7 +22,7 @@ internal abstract class ImportAdderService : ILanguageService
Document document, IEnumerable<TextSpan> spans,
OptionSet options, CancellationToken cancellationToken)
{
options = options ?? await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
options ??= await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
......
......@@ -45,7 +45,7 @@ private SyntaxNode ApplyTrackingToNewNode(SyntaxNode node)
return null;
}
_lazyTrackedNewNodesOpt = _lazyTrackedNewNodesOpt ?? new HashSet<SyntaxNode>();
_lazyTrackedNewNodesOpt ??= new HashSet<SyntaxNode>();
foreach (var descendant in node.DescendantNodesAndSelf())
{
_lazyTrackedNewNodesOpt.Add(descendant);
......
......@@ -282,7 +282,7 @@ bool metadataTypeMatches(SymbolAndProjectIdSet s, INamedTypeSymbol t)
CancellationToken cancellationToken)
{
type = type.WithSymbol(type.Symbol.OriginalDefinition);
projects = projects ?? ImmutableHashSet.Create(solution.Projects.ToArray());
projects ??= ImmutableHashSet.Create(solution.Projects.ToArray());
var searchInMetadata = type.Symbol.Locations.Any(s_isInMetadata);
// Note: it is not sufficient to just walk the list of projects passed in,
......
......@@ -182,7 +182,7 @@ protected static bool IdentifiersMatch(ISyntaxFactsService syntaxFacts, string n
ISymbol symbol, Func<SyntaxToken, SyntaxNode> findParentNode, Solution solution, CancellationToken cancellationToken)
{
var nodeMatch = GetStandardSymbolsNodeMatchFunction(symbol, solution, cancellationToken);
findParentNode = findParentNode ?? (t => t.Parent);
findParentNode ??= (t => t.Parent);
(bool matched, CandidateReason reason) symbolsMatch(SyntaxToken token, SemanticModel model)
=> nodeMatch(findParentNode(token), model);
......
......@@ -48,7 +48,7 @@ public static partial class SymbolFinder
FindReferencesSearchOptions options, CancellationToken cancellationToken)
{
var finders = ReferenceFinders.DefaultReferenceFinders;
progress = progress ?? StreamingFindReferencesProgress.Instance;
progress ??= StreamingFindReferencesProgress.Instance;
var engine = new FindReferencesSearchEngine(
solution, documents, finders, progress, options, cancellationToken);
return engine.FindReferencesAsync(symbolAndProjectId);
......
......@@ -79,7 +79,7 @@ public static partial class SymbolFinder
FindReferencesSearchOptions options,
CancellationToken cancellationToken)
{
progress = progress ?? FindReferencesProgress.Instance;
progress ??= FindReferencesProgress.Instance;
var streamingProgress = new StreamingProgressCollector(
new StreamingFindReferencesProgressAdapter(progress));
await FindReferencesAsync(
......
......@@ -256,7 +256,7 @@ public static partial class SymbolFinder
var bestDef = sourceDef.Symbol != null ? sourceDef : implementation;
if (IsAccessible(bestDef))
{
results = results ?? ImmutableArray.CreateBuilder<SymbolAndProjectId>();
results ??= ImmutableArray.CreateBuilder<SymbolAndProjectId>();
results.Add(bestDef.WithSymbol(bestDef.Symbol.OriginalDefinition));
}
}
......@@ -317,7 +317,7 @@ public static async Task<IEnumerable<SymbolCallerInfo>> FindCallersAsync(ISymbol
{
foreach (var kvp in await directReferences.Locations.FindReferencingSymbolsAsync(cancellationToken).ConfigureAwait(false))
{
results = results ?? new List<SymbolCallerInfo>();
results ??= new List<SymbolCallerInfo>();
results.Add(new SymbolCallerInfo(kvp.Key, symbol, kvp.Value, isDirect: true));
}
}
......@@ -326,7 +326,7 @@ public static async Task<IEnumerable<SymbolCallerInfo>> FindCallersAsync(ISymbol
var indirectLocations = indirectReferences.SelectMany(r => r.Locations);
foreach (var kvp in await indirectLocations.FindReferencingSymbolsAsync(cancellationToken).ConfigureAwait(false))
{
results = results ?? new List<SymbolCallerInfo>();
results ??= new List<SymbolCallerInfo>();
results.Add(new SymbolCallerInfo(kvp.Key, symbol, kvp.Value, isDirect: false));
}
}
......
......@@ -211,7 +211,7 @@ public SymbolTreeInfo WithChecksum(Checksum checksum)
foreach (var node in FindNodeIndices(name, comparer))
{
cancellationToken.ThrowIfCancellationRequested();
assemblySymbol = assemblySymbol ?? await lazyAssembly.GetValueAsync(cancellationToken).ConfigureAwait(false);
assemblySymbol ??= await lazyAssembly.GetValueAsync(cancellationToken).ConfigureAwait(false);
Bind(node, assemblySymbol.GlobalNamespace, results, cancellationToken);
}
......
......@@ -50,7 +50,7 @@ internal static class LValueFlowCapturesProvider
assignment.Target == flowCaptureReference ||
flowCaptureReference.IsInLeftOfDeconstructionAssignment(out _))
{
lvalueFlowCaptureIdBuilder = lvalueFlowCaptureIdBuilder ?? ImmutableDictionary.CreateBuilder<CaptureId, FlowCaptureKind>();
lvalueFlowCaptureIdBuilder ??= ImmutableDictionary.CreateBuilder<CaptureId, FlowCaptureKind>();
var captureKind = flowCaptureReference.Parent.IsAnyCompoundAssignment() || rvalueFlowCaptureIds.Contains(flowCaptureReference.Id)
? FlowCaptureKind.LValueAndRValueCapture
: FlowCaptureKind.LValueCapture;
......
......@@ -76,7 +76,7 @@ public IFormattingResult Format(SyntaxNode node, IEnumerable<TextSpan> spans, Op
continue;
}
results = results ?? new List<AbstractFormattingResult>();
results ??= new List<AbstractFormattingResult>();
results.Add(Format(node, options, rules, pair.Item1, pair.Item2, cancellationToken));
}
......
......@@ -243,9 +243,9 @@ internal static IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerab
return null;
}
options = options ?? workspace.Options;
rules = rules ?? GetDefaultFormattingRules(workspace, node.Language);
spans = spans ?? SpecializedCollections.SingletonEnumerable(node.FullSpan);
options ??= workspace.Options;
rules ??= GetDefaultFormattingRules(workspace, node.Language);
spans ??= SpecializedCollections.SingletonEnumerable(node.FullSpan);
return languageFormatter.Format(node, spans, options, rules, cancellationToken);
}
......
......@@ -112,7 +112,7 @@ internal async Task<LinkedFileMergeSessionResult> MergeDiffsAsync(IMergeConflict
if (unmergedChanges.Any())
{
mergeConflictHandler = mergeConflictHandler ?? _oldSolution.GetDocument(linkedDocumentGroup.First()).GetLanguageService<ILinkedFileMergeConflictCommentAdditionService>();
mergeConflictHandler ??= _oldSolution.GetDocument(linkedDocumentGroup.First()).GetLanguageService<ILinkedFileMergeConflictCommentAdditionService>();
var mergeConflictTextEdits = mergeConflictHandler.CreateEdits(originalSourceText, unmergedChanges);
allChanges = MergeChangesWithMergeFailComments(appliedChanges, mergeConflictTextEdits, mergeConflictResolutionSpan, groupSessionInfo);
......
......@@ -48,7 +48,7 @@ internal abstract partial class PatternMatcher : IDisposable
CultureInfo culture,
bool allowFuzzyMatching = false)
{
culture = culture ?? CultureInfo.CurrentCulture;
culture ??= CultureInfo.CurrentCulture;
_compareInfo = culture.CompareInfo;
_textInfo = culture.TextInfo;
......@@ -534,12 +534,12 @@ private bool PartStartsWith(string candidate, TextSpan candidatePart, string pat
matchSpans.Add(new TextSpan(candidateHump.Start, patternChunkCharacterSpan.Length));
gotOneMatchThisCandidate = true;
firstMatch = firstMatch ?? currentCandidateHump;
firstMatch ??= currentCandidateHump;
// If we were contiguous, then keep that value. If we weren't, then keep that
// value. If we don't know, then set the value to 'true' as an initial match is
// obviously contiguous.
contiguous = contiguous ?? true;
contiguous ??= true;
candidateHump = new TextSpan(candidateHump.Start + patternChunkCharacterSpan.Length, candidateHump.Length - patternChunkCharacterSpan.Length);
}
......
......@@ -44,7 +44,7 @@ public static class Recommender
OptionSet options = null,
CancellationToken cancellationToken = default)
{
options = options ?? workspace.Options;
options ??= workspace.Options;
var languageRecommender = workspace.Services.GetLanguageServices(semanticModel.Language).GetService<IRecommendationService>();
return await languageRecommender.GetRecommendedSymbolsAtPositionAsync(
......
......@@ -345,7 +345,7 @@ private async Task DebugVerifyNoErrorsAsync(ConflictResolution conflictResolutio
var hasConflict = _renameAnnotations.HasAnnotation(tokenOrNode, RenameInvalidIdentifierAnnotation.Instance);
if (!hasConflict)
{
newDocumentSemanticModel = newDocumentSemanticModel ?? await newDocument.GetSemanticModelAsync(_cancellationToken).ConfigureAwait(false);
newDocumentSemanticModel ??= await newDocument.GetSemanticModelAsync(_cancellationToken).ConfigureAwait(false);
newReferencedSymbols = GetSymbolsInNewSolution(newDocument, newDocumentSemanticModel, conflictAnnotation, tokenOrNode);
// The semantic correctness, after rename, for each token of interest in the
......
......@@ -44,7 +44,7 @@ public static class Renamer
cancellationToken.ThrowIfCancellationRequested();
options = options ?? solution.Options;
options ??= solution.Options;
return RenameLocations.FindAsync(
symbolAndProjectId, solution, options, cancellationToken);
}
......@@ -100,7 +100,7 @@ public static class Renamer
cancellationToken.ThrowIfCancellationRequested();
options = options ?? solution.Workspace.Options;
options ??= solution.Workspace.Options;
var renameLocations = await GetRenameLocationsAsync(solution, symbolAndProjectId, options, cancellationToken).ConfigureAwait(false);
return await RenameAsync(renameLocations, newName, filter, hasConflict, cancellationToken).ConfigureAwait(false);
}
......
......@@ -122,7 +122,7 @@ public static async Task<ImmutableArray<Diagnostic>> GetErrorsAsync(this Documen
return ImmutableArray<Diagnostic>.Empty;
}
ignoreErrorCode = ignoreErrorCode ?? SpecializedCollections.EmptyList<string>();
ignoreErrorCode ??= SpecializedCollections.EmptyList<string>();
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
return semanticModel.GetDiagnostics(cancellationToken: cancellationToken).WhereAsArray(
diag => diag.Severity == DiagnosticSeverity.Error && !ignoreErrorCode.Contains(diag.Id));
......
......@@ -711,7 +711,7 @@ public static bool IsInaccessibleLocal(this ISymbol symbol, int position)
}
attributes = attributes.IsDefault ? symbol.GetAttributes() : attributes;
hideModuleNameAttribute = hideModuleNameAttribute ?? compilation.HideModuleNameAttribute();
hideModuleNameAttribute ??= compilation.HideModuleNameAttribute();
foreach (var attribute in attributes)
{
if (Equals(attribute.AttributeClass, hideModuleNameAttribute))
......@@ -726,7 +726,7 @@ public static bool IsInaccessibleLocal(this ISymbol symbol, int position)
private static bool IsBrowsingProhibitedByEditorBrowsableAttribute(
ISymbol symbol, ImmutableArray<AttributeData> attributes, bool hideAdvancedMembers, Compilation compilation, IMethodSymbol constructor)
{
constructor = constructor ?? EditorBrowsableHelpers.GetSpecialEditorBrowsableAttributeConstructor(compilation);
constructor ??= EditorBrowsableHelpers.GetSpecialEditorBrowsableAttributeConstructor(compilation);
if (constructor == null)
{
return false;
......
......@@ -217,7 +217,7 @@ public static ITypeSymbol RemoveNullableIfPresent(this ITypeSymbol symbol)
this ITypeSymbol type,
HashSet<INamedTypeSymbol> symbols = null)
{
symbols = symbols ?? new HashSet<INamedTypeSymbol>(SymbolEquivalenceComparer.Instance);
symbols ??= new HashSet<INamedTypeSymbol>(SymbolEquivalenceComparer.Instance);
foreach (var interfaceType in type.Interfaces)
{
......@@ -467,7 +467,7 @@ public static bool IsFormattableString(this ITypeSymbol symbol)
public static IList<ITypeParameterSymbol> GetReferencedMethodTypeParameters(
this ITypeSymbol type, IList<ITypeParameterSymbol> result = null)
{
result = result ?? new List<ITypeParameterSymbol>();
result ??= new List<ITypeParameterSymbol>();
type?.Accept(new CollectTypeParameterSymbolsVisitor(result, onlyMethodTypeParameters: true));
return result;
}
......@@ -475,7 +475,7 @@ public static bool IsFormattableString(this ITypeSymbol symbol)
public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(
this ITypeSymbol type, IList<ITypeParameterSymbol> result = null)
{
result = result ?? new List<ITypeParameterSymbol>();
result ??= new List<ITypeParameterSymbol>();
type?.Accept(new CollectTypeParameterSymbolsVisitor(result, onlyMethodTypeParameters: false));
return result;
}
......
......@@ -324,7 +324,7 @@ public void Add(string value)
private int GetBitArrayIndex(string value, int i)
{
var hash = ComputeHash(value, i);
hash = hash % _bitArray.Length;
hash %= _bitArray.Length;
return Math.Abs(hash);
}
......@@ -339,7 +339,7 @@ public void Add(long value)
private int GetBitArrayIndex(long value, int i)
{
var hash = ComputeHash(value, i);
hash = hash % _bitArray.Length;
hash %= _bitArray.Length;
return Math.Abs(hash);
}
......
......@@ -61,7 +61,7 @@ internal static IList<string> EnsureUniqueness(IList<string> names, bool isCaseS
Func<string, bool> canUse,
bool isCaseSensitive = true)
{
canUse = canUse ?? (s => true);
canUse ??= (s => true);
// Don't enumerate as we will be modifying the collection in place.
for (var i = 0; i < names.Count; i++)
......
......@@ -59,7 +59,7 @@ protected virtual SyntaxNode TransformReducedNode(SyntaxNode reducedNode, Syntax
return document;
}
optionSet = optionSet ?? await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
optionSet ??= await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
......
......@@ -85,7 +85,7 @@ public IList<string> Find(string value, int? threshold = null)
lowerCaseCharacters[i] = CaseInsensitiveComparison.ToLower(value[i]);
}
threshold = threshold ?? WordSimilarityChecker.GetThreshold(value);
threshold ??= WordSimilarityChecker.GetThreshold(value);
var result = new List<string>();
Lookup(_nodes[0], lowerCaseCharacters, value.Length, threshold.Value, result, recursionCount: 0);
return result;
......
......@@ -1003,7 +1003,7 @@ private static int CountBits(uint v)
{
unchecked
{
v = v - ((v >> 1) & 0x55555555u);
v -= ((v >> 1) & 0x55555555u);
v = (v & 0x33333333u) + ((v >> 2) & 0x33333333u);
return (int)((v + (v >> 4) & 0xF0F0F0Fu) * 0x1010101u) >> 24;
}
......
......@@ -15,7 +15,7 @@ internal static class Contract
{
if (value == null)
{
message = message ?? "Unexpected Null";
message ??= "Unexpected Null";
Fail(message);
}
}
......@@ -28,7 +28,7 @@ public static void ThrowIfFalse(bool condition, string message = null)
{
if (!condition)
{
message = message ?? "Unexpected false";
message ??= "Unexpected false";
Fail(message);
}
}
......@@ -41,7 +41,7 @@ public static void ThrowIfTrue(bool condition, string message = null)
{
if (condition)
{
message = message ?? "Unexpected true";
message ??= "Unexpected true";
Fail(message);
}
}
......
......@@ -49,7 +49,7 @@ internal async static Task<PooledStream> CreateReadableStreamAsync(Stream stream
var bytesRead = await stream.ReadAsync(chunk, chunkOffset, count, cancellationToken).ConfigureAwait(false);
if (bytesRead > 0)
{
count = count - bytesRead;
count -= bytesRead;
chunkOffset += bytesRead;
}
else
......
......@@ -22,7 +22,7 @@ public WorkspaceTaskQueue(WorkspaceTaskSchedulerFactory factory, TaskScheduler t
private T3 ScheduleTask<T1, T2, T3>(Func<T1, T2, T3> taskScheduler, string taskName, T1 arg1, T2 arg2) where T3 : Task
{
taskName = taskName ?? GetType().Name + ".Task";
taskName ??= GetType().Name + ".Task";
var asyncToken = _factory.BeginAsyncOperation(taskName);
var task = taskScheduler(arg1, arg2);
......
......@@ -24,7 +24,7 @@ public WorkspaceTaskScheduler(WorkspaceTaskSchedulerFactory factory, TaskSchedul
string taskName, Func<TTask> taskCreator)
where TTask : Task
{
taskName = taskName ?? GetType().Name + ".ScheduleTask";
taskName ??= GetType().Name + ".ScheduleTask";
var asyncToken = _factory.BeginAsyncOperation(taskName);
var task = taskCreator();
......
......@@ -42,7 +42,7 @@ public static SolutionId CreateFromSerialized(Guid id, string debugName = null)
throw new ArgumentException(nameof(id));
}
debugName = debugName ?? "unsaved";
debugName ??= "unsaved";
return new SolutionId(id, debugName);
}
......
......@@ -185,13 +185,13 @@ private void CheckInvariants()
{
var branchId = GetBranchId();
solutionAttributes = solutionAttributes ?? _solutionAttributes;
projectIds = projectIds ?? _projectIds;
idToProjectStateMap = idToProjectStateMap ?? _projectIdToProjectStateMap;
projectIdToTrackerMap = projectIdToTrackerMap ?? _projectIdToTrackerMap;
filePathToDocumentIdsMap = filePathToDocumentIdsMap ?? _filePathToDocumentIdsMap;
dependencyGraph = dependencyGraph ?? _dependencyGraph;
lazyLatestProjectVersion = lazyLatestProjectVersion ?? _lazyLatestProjectVersion;
solutionAttributes ??= _solutionAttributes;
projectIds ??= _projectIds;
idToProjectStateMap ??= _projectIdToProjectStateMap;
projectIdToTrackerMap ??= _projectIdToTrackerMap;
filePathToDocumentIdsMap ??= _filePathToDocumentIdsMap;
dependencyGraph ??= _dependencyGraph;
lazyLatestProjectVersion ??= _lazyLatestProjectVersion;
if (branchId == _branchId &&
solutionAttributes == _solutionAttributes &&
......@@ -1670,7 +1670,7 @@ private SolutionState WithAnalyzerConfigDocumentState(AnalyzerConfigDocumentStat
var projectId = newProjectState.Id;
var newStateMap = _projectIdToProjectStateMap.SetItem(projectId, newProjectState);
newDependencyGraph = newDependencyGraph ?? _dependencyGraph;
newDependencyGraph ??= _dependencyGraph;
var newTrackerMap = CreateCompilationTrackerMap(projectId, newDependencyGraph);
// If we have a tracker for this project, then fork it as well (along with the
// translation action and store it in the tracker map.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册