diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs index 54a1cc9ac1f48457b5e8eccdad1e3579e1e92ca3..4233d43ae409ffe07ebd43d0ab607b0b5cb8179e 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationHelpers.cs @@ -36,7 +36,7 @@ internal static class CSharpCodeGenerationHelpers CodeGenerationOptions options, Accessibility defaultAccessibility) { - options = options ?? CodeGenerationOptions.Default; + options ??= CodeGenerationOptions.Default; if (!options.GenerateDefaultAccessibility && accessibility == defaultAccessibility) { return; diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index e8cf89e077c83e1ee50ccbc8ce6c3b0292990d5b..d95a5f1515fbcfd677ec0cede551fc61a176782a 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -1501,7 +1501,7 @@ public override SyntaxNode WithModifiers(SyntaxNode declaration, DeclarationModi private SyntaxNode WithModifiersInternal(SyntaxNode declaration, DeclarationModifiers modifiers) { - modifiers = modifiers & GetAllowedModifiers(declaration.Kind()); + modifiers &= GetAllowedModifiers(declaration.Kind()); var existingModifiers = this.GetModifiers(declaration); if (modifiers != existingModifiers) @@ -1697,51 +1697,51 @@ private static void GetAccessibilityAndModifiers(SyntaxTokenList modifierList, o break; case SyntaxKind.AbstractKeyword: - modifiers = modifiers | DeclarationModifiers.Abstract; + modifiers |= DeclarationModifiers.Abstract; break; case SyntaxKind.NewKeyword: - modifiers = modifiers | DeclarationModifiers.New; + modifiers |= DeclarationModifiers.New; break; case SyntaxKind.OverrideKeyword: - modifiers = modifiers | DeclarationModifiers.Override; + modifiers |= DeclarationModifiers.Override; break; case SyntaxKind.VirtualKeyword: - modifiers = modifiers | DeclarationModifiers.Virtual; + modifiers |= DeclarationModifiers.Virtual; break; case SyntaxKind.StaticKeyword: - modifiers = modifiers | DeclarationModifiers.Static; + modifiers |= DeclarationModifiers.Static; break; case SyntaxKind.AsyncKeyword: - modifiers = modifiers | DeclarationModifiers.Async; + modifiers |= DeclarationModifiers.Async; break; case SyntaxKind.ConstKeyword: - modifiers = modifiers | DeclarationModifiers.Const; + modifiers |= DeclarationModifiers.Const; break; case SyntaxKind.ReadOnlyKeyword: - modifiers = modifiers | DeclarationModifiers.ReadOnly; + modifiers |= DeclarationModifiers.ReadOnly; break; case SyntaxKind.SealedKeyword: - modifiers = modifiers | DeclarationModifiers.Sealed; + modifiers |= DeclarationModifiers.Sealed; break; case SyntaxKind.UnsafeKeyword: - modifiers = modifiers | DeclarationModifiers.Unsafe; + modifiers |= DeclarationModifiers.Unsafe; break; case SyntaxKind.PartialKeyword: - modifiers = modifiers | DeclarationModifiers.Partial; + modifiers |= DeclarationModifiers.Partial; break; case SyntaxKind.RefKeyword: - modifiers = modifiers | DeclarationModifiers.Ref; + modifiers |= DeclarationModifiers.Ref; break; } } diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/ConstructorGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/ConstructorGenerator.cs index 97c417c95049d4a3fb5ef7abdf7e844eece7fc79..2b30516fa675cb92e4de33f7ff769868f2e04d99 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/ConstructorGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/ConstructorGenerator.cs @@ -44,7 +44,7 @@ private static MemberDeclarationSyntax LastConstructorOrField(SyntaxList(constructor, options); if (reusableSyntax != null) diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs index 81882adf2305e1c0762f8ea5bc67ab02e5e812c3..c0d43e77989e1e6bb7fc56333a3cbc623f7839f7 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs @@ -36,7 +36,7 @@ private static MemberDeclarationSyntax LastConstructorOrField(SyntaxList(destructor, options); if (reusableSyntax != null) diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/MethodGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/MethodGenerator.cs index 10767c9c538af968ae4e03743109530b1684730e..2e77ad7dcfd17edd6956101f5481a82bfdfbd364 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/MethodGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/MethodGenerator.cs @@ -66,7 +66,7 @@ internal static class MethodGenerator Workspace workspace, CodeGenerationOptions options, ParseOptions parseOptions) { - options = options ?? CodeGenerationOptions.Default; + options ??= CodeGenerationOptions.Default; var reusableSyntax = GetReuseableSyntaxNodeForSymbol(method, options); if (reusableSyntax != null) diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs index dace9ebfed3a7ca5a9951302ff401300ddf77348..b4a7b33f90ada29e7fbb04c506e7e03f77ee55d5 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/NamedTypeGenerator.cs @@ -64,7 +64,7 @@ internal static class NamedTypeGenerator CodeGenerationOptions options, CancellationToken cancellationToken) { - options = options ?? CodeGenerationOptions.Default; + options ??= CodeGenerationOptions.Default; var declaration = GetDeclarationSyntaxWithoutMembers(namedType, destination, options); diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs index 8db65b398af15eb042416eb293ab98396d5ff2e0..6562850ffb9b1d7b39788ba49806296d3076f535 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/NamespaceGenerator.cs @@ -58,7 +58,7 @@ internal static class NamespaceGenerator CodeGenerationOptions options, CancellationToken cancellationToken) { - options = options ?? CodeGenerationOptions.Default; + options ??= CodeGenerationOptions.Default; GetNameAndInnermostNamespace(@namespace, options, out var name, out var innermostNamespace); var declaration = GetDeclarationSyntaxWithoutMembers(@namespace, innermostNamespace, name, options); diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs index d4fb49b9ca7b9b46df5effdc503d3f4bf2e597a9..41b4a18c65500354e22f13b8a58efb3eeced260b 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -225,7 +225,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi return false; } - validTypeDeclarations = validTypeDeclarations ?? SpecializedCollections.EmptySet(); + validTypeDeclarations ??= SpecializedCollections.EmptySet(); // Check many of the simple cases first. var leftToken = contextOpt != null @@ -262,7 +262,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi return false; } - validModifiers = validModifiers ?? SpecializedCollections.EmptySet(); + validModifiers ??= SpecializedCollections.EmptySet(); if (modifierTokens.IsSubsetOf(validModifiers)) { @@ -517,7 +517,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi ? contextOpt.ContainingTypeDeclaration : syntaxTree.GetContainingTypeDeclaration(position, cancellationToken); - validTypeDeclarations = validTypeDeclarations ?? SpecializedCollections.EmptySet(); + validTypeDeclarations ??= SpecializedCollections.EmptySet(); if (typeDecl != null) { @@ -570,7 +570,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi return false; } - validModifiers = validModifiers ?? SpecializedCollections.EmptySet(); + validModifiers ??= SpecializedCollections.EmptySet(); if (modifierTokens.IsProperSubsetOf(validModifiers)) { diff --git a/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs index 6380b1f77bca3174f78590a82f219d5d30c17fd9..10ef5a98d813f1986ce9e18e05ab1be8e158179e 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/SemanticModelExtensions.cs @@ -309,7 +309,7 @@ private static bool CanBindToken(SyntaxToken token) IList reservedNames, CancellationToken cancellationToken) { - reservedNames = reservedNames ?? SpecializedCollections.EmptyList(); + reservedNames ??= SpecializedCollections.EmptyList(); // We can't change the names of named parameters. Any other names we're flexible on. var isFixed = reservedNames.Select(s => true).Concat( @@ -328,7 +328,7 @@ private static bool CanBindToken(SyntaxToken token) NamingRule parameterNamingRule, CancellationToken cancellationToken) { - reservedNames = reservedNames ?? SpecializedCollections.EmptyList(); + reservedNames ??= SpecializedCollections.EmptyList(); // We can't change the names of named parameters. Any other names we're flexible on. var isFixed = reservedNames.Select(s => true).Concat( @@ -360,7 +360,7 @@ private static ImmutableArray GenerateNames(IList reserve IList reservedNames, CancellationToken cancellationToken) { - reservedNames = reservedNames ?? SpecializedCollections.EmptyList(); + reservedNames ??= SpecializedCollections.EmptyList(); // We can't change the names of named parameters. Any other names we're flexible on. var isFixed = reservedNames.Select(s => true).Concat( @@ -379,7 +379,7 @@ private static ImmutableArray GenerateNames(IList reserve NamingRule parameterNamingRule, CancellationToken cancellationToken) { - reservedNames = reservedNames ?? SpecializedCollections.EmptyList(); + reservedNames ??= SpecializedCollections.EmptyList(); // We can't change the names of named parameters. Any other names we're flexible on. var isFixed = reservedNames.Select(s => true).Concat( @@ -403,7 +403,7 @@ public static ISet GetUsingNamespacesInScope(this SemanticMode var symbolInfo = semanticModel.GetSymbolInfo(@using.Name); if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Namespace) { - result = result ?? new HashSet(); + result ??= new HashSet(); result.Add((INamespaceSymbol)symbolInfo.Symbol); } } diff --git a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs index 646941ab2d35944e48520fe469fa485130c4d006..a1f0fa294b5bfdaffe6d2c4de25397b768736e27 100644 --- a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs +++ b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs @@ -97,7 +97,7 @@ private void ProcessUsings(List> aliasMaps, SyntaxLis var mappedName = GetTypeName(usingDecl.Name); if (mappedName != null) { - aliasMap = aliasMap ?? AllocateAliasMap(); + aliasMap ??= AllocateAliasMap(); // If we have: using X = Goo, then we store a mapping from X -> Goo // here. That way if we see a class that inherits from X we also state diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.cs b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.cs index 374c6c6e00c6c1fc69570e4315e2934ac22287ba..81e5c7752adfe7f9a50f6afe2f0fa3e2730c98b7 100644 --- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.cs +++ b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.cs @@ -46,13 +46,13 @@ public override ParseOptions GetDefaultParseOptionsWithLatestLanguageVersion() public override SyntaxTree CreateSyntaxTree(string fileName, ParseOptions options, Encoding encoding, SyntaxNode root) { - options = options ?? GetDefaultParseOptions(); + options ??= GetDefaultParseOptions(); return SyntaxFactory.SyntaxTree(root, options, fileName, encoding); } public override SyntaxTree ParseSyntaxTree(string filePath, ParseOptions options, SourceText text, ImmutableDictionary treeDiagnosticReportingOptionsOpt, CancellationToken cancellationToken) { - options = options ?? GetDefaultParseOptions(); + options ??= GetDefaultParseOptions(); return SyntaxFactory.ParseSyntaxTree(text, options, filePath, treeDiagnosticReportingOptionsOpt, cancellationToken: cancellationToken); } diff --git a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs index 64753cce5f1d9bc2f269b63c81441c8c6c3a7cdd..2e9a86afd873d384b9a60018351ac55593136f53 100644 --- a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs +++ b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs @@ -589,7 +589,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri if (!string.IsNullOrEmpty(suffix)) { - currentNewIdentifier = currentNewIdentifier + suffix; + currentNewIdentifier += suffix; } }