diff --git a/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs index 2a485b5ab7d9f..344447bb54886 100644 --- a/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs @@ -53,7 +53,7 @@ private void AnalyzeOperation(OperationAnalysisContext context) !tree.OverlapsHiddenPosition(switchBlock.Span, context.CancellationToken)) { Debug.Assert(missingCases || missingDefaultCase); - var properties = ImmutableDictionary.Empty + var properties = ImmutableDictionary.Empty .Add(PopulateSwitchStatementHelpers.MissingCases, missingCases.ToString()) .Add(PopulateSwitchStatementHelpers.MissingDefaultCase, missingDefaultCase.ToString()); diff --git a/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs index 56de02a2bcf12..a2a91a7ab625c 100644 --- a/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs @@ -58,8 +58,8 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) { var diagnostic = context.Diagnostics.First(); var properties = diagnostic.Properties; - var missingCases = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingCases]); - var missingDefaultCase = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingDefaultCase]); + var missingCases = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingCases]!); + var missingDefaultCase = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingDefaultCase]!); Debug.Assert(missingCases || missingDefaultCase); @@ -137,8 +137,8 @@ private async Task FixOneDiagnosticAsync( bool addCases, bool addDefaultCase, bool onlyOneDiagnostic, CancellationToken cancellationToken) { - var hasMissingCases = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingCases]); - var hasMissingDefaultCase = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingDefaultCase]); + var hasMissingCases = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingCases]!); + var hasMissingDefaultCase = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingDefaultCase]!); var switchLocation = diagnostic.AdditionalLocations[0]; var switchNode = switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken) as TSwitchSyntax; diff --git a/src/Compilers/Core/Portable/CommandLine/SarifErrorLogger.cs b/src/Compilers/Core/Portable/CommandLine/SarifErrorLogger.cs index 65e64c51905af..3c4731822ef6a 100644 --- a/src/Compilers/Core/Portable/CommandLine/SarifErrorLogger.cs +++ b/src/Compilers/Core/Portable/CommandLine/SarifErrorLogger.cs @@ -71,7 +71,7 @@ protected static string GetLevel(DiagnosticSeverity severity) case DiagnosticSeverity.Hidden: default: - // hidden diagnostics are not reported on the command line and therefore not currently given to + // hidden diagnostics are not reported on the command line and therefore not currently given to // the error logger. We could represent it with a custom property in the SARIF log if that changes. Debug.Assert(false); goto case DiagnosticSeverity.Warning; @@ -124,7 +124,7 @@ protected static string GetUri(string path) { Debug.Assert(!string.IsNullOrEmpty(path)); - // Note that in general, these "paths" are opaque strings to be + // Note that in general, these "paths" are opaque strings to be // interpreted by resolvers (see SyntaxTree.FilePath documentation). // Common case: absolute path -> absolute URI diff --git a/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs b/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs index eed63550dbc27..bc2dc55a2ab56 100644 --- a/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs +++ b/src/Compilers/Core/Portable/Diagnostic/Diagnostic.DiagnosticWithProgrammaticSuppression.cs @@ -80,7 +80,7 @@ public override IReadOnlyList AdditionalLocations get { return _originalUnsuppressedDiagnostic.AdditionalLocations; } } - public override ImmutableDictionary Properties + public override ImmutableDictionary Properties { get { return _originalUnsuppressedDiagnostic.Properties; } } diff --git a/src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs b/src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs index cb7b7a2451348..ac6ada2082cb3 100644 --- a/src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs +++ b/src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs @@ -37,8 +37,8 @@ public abstract partial class Diagnostic : IEquatable, IFormattable /// The instance. public static Diagnostic Create( DiagnosticDescriptor descriptor, - Location location, - params object?[] messageArgs) + Location? location, + params object?[]? messageArgs) { return Create(descriptor, location, null, null, messageArgs); } @@ -57,9 +57,9 @@ public static Diagnostic Create( /// The instance. public static Diagnostic Create( DiagnosticDescriptor descriptor, - Location location, - ImmutableDictionary? properties, - params object?[] messageArgs) + Location? location, + ImmutableDictionary? properties, + params object?[]? messageArgs) { return Create(descriptor, location, null, properties, messageArgs); } @@ -78,9 +78,9 @@ public static Diagnostic Create( /// The instance. public static Diagnostic Create( DiagnosticDescriptor descriptor, - Location location, + Location? location, IEnumerable? additionalLocations, - params object?[] messageArgs) + params object?[]? messageArgs) { return Create(descriptor, location, additionalLocations, properties: null, messageArgs: messageArgs); } @@ -104,10 +104,10 @@ public static Diagnostic Create( /// The instance. public static Diagnostic Create( DiagnosticDescriptor descriptor, - Location location, + Location? location, IEnumerable? additionalLocations, - ImmutableDictionary? properties, - params object?[] messageArgs) + ImmutableDictionary? properties, + params object?[]? messageArgs) { return Create(descriptor, location, effectiveSeverity: descriptor.DefaultSeverity, additionalLocations, properties, messageArgs); } @@ -132,11 +132,11 @@ public static Diagnostic Create( /// The instance. public static Diagnostic Create( DiagnosticDescriptor descriptor, - Location location, + Location? location, DiagnosticSeverity effectiveSeverity, IEnumerable? additionalLocations, - ImmutableDictionary? properties, - params object?[] messageArgs) + ImmutableDictionary? properties, + params object?[]? messageArgs) { if (descriptor == null) { @@ -197,7 +197,7 @@ public static Diagnostic Create( Location? location = null, IEnumerable? additionalLocations = null, IEnumerable? customTags = null, - ImmutableDictionary? properties = null) + ImmutableDictionary? properties = null) { return Create(id, category, message, severity, defaultSeverity, isEnabledByDefault, warningLevel, false, title, description, helpLink, location, additionalLocations, customTags, properties); @@ -248,7 +248,7 @@ public static Diagnostic Create( Location? location = null, IEnumerable? additionalLocations = null, IEnumerable? customTags = null, - ImmutableDictionary? properties = null) + ImmutableDictionary? properties = null) { if (id == null) { @@ -398,8 +398,8 @@ public bool IsWarningAsError /// if there is no entry. This can be used to put diagnostic specific information you want /// to pass around. for example, to corresponding fixer. /// - public virtual ImmutableDictionary Properties - => ImmutableDictionary.Empty; + public virtual ImmutableDictionary Properties + => ImmutableDictionary.Empty; string IFormattable.ToString(string? ignored, IFormatProvider? formatProvider) { diff --git a/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs b/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs index 1906545d14b9c..5676246815d2a 100644 --- a/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs +++ b/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs @@ -26,7 +26,7 @@ internal sealed class SimpleDiagnostic : Diagnostic private readonly Location _location; private readonly IReadOnlyList _additionalLocations; private readonly object?[] _messageArgs; - private readonly ImmutableDictionary _properties; + private readonly ImmutableDictionary _properties; private readonly bool _isSuppressed; private SimpleDiagnostic( @@ -36,7 +36,7 @@ private SimpleDiagnostic( Location location, IEnumerable? additionalLocations, object?[]? messageArgs, - ImmutableDictionary? properties, + ImmutableDictionary? properties, bool isSuppressed) { if ((warningLevel == 0 && severity != DiagnosticSeverity.Error) || @@ -51,7 +51,7 @@ private SimpleDiagnostic( _location = location ?? Location.None; _additionalLocations = additionalLocations?.ToImmutableArray() ?? SpecializedCollections.EmptyReadOnlyList(); _messageArgs = messageArgs ?? Array.Empty(); - _properties = properties ?? ImmutableDictionary.Empty; + _properties = properties ?? ImmutableDictionary.Empty; _isSuppressed = isSuppressed; } @@ -62,7 +62,7 @@ internal static SimpleDiagnostic Create( Location location, IEnumerable? additionalLocations, object?[]? messageArgs, - ImmutableDictionary? properties, + ImmutableDictionary? properties, bool isSuppressed = false) { return new SimpleDiagnostic(descriptor, severity, warningLevel, location, additionalLocations, messageArgs, properties, isSuppressed); @@ -72,7 +72,7 @@ internal static SimpleDiagnostic Create(string id, LocalizableString title, stri DiagnosticSeverity severity, DiagnosticSeverity defaultSeverity, bool isEnabledByDefault, int warningLevel, Location location, IEnumerable? additionalLocations, IEnumerable? customTags, - ImmutableDictionary? properties, bool isSuppressed = false) + ImmutableDictionary? properties, bool isSuppressed = false) { var descriptor = new DiagnosticDescriptor(id, title, message, category, defaultSeverity, isEnabledByDefault, description, helpLink, customTags.ToImmutableArrayOrEmpty()); @@ -139,7 +139,7 @@ public override IReadOnlyList AdditionalLocations get { return _additionalLocations; } } - public override ImmutableDictionary Properties + public override ImmutableDictionary Properties { get { return _properties; } } diff --git a/src/Compilers/Core/Portable/InternalUtilities/JsonWriter.cs b/src/Compilers/Core/Portable/InternalUtilities/JsonWriter.cs index d7aa84a665bb0..c2145b5a05c74 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/JsonWriter.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/JsonWriter.cs @@ -78,7 +78,7 @@ public void WriteKey(string key) _pending = Pending.None; } - public void Write(string key, string value) + public void Write(string key, string? value) { WriteKey(key); Write(value); @@ -96,7 +96,7 @@ public void Write(string key, bool value) Write(value); } - public void Write(string value) + public void Write(string? value) { WritePending(); _output.Write('"'); diff --git a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs index 0bd67370e1d66..3f16f3bdef109 100644 --- a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs +++ b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs @@ -240,7 +240,7 @@ static string GetLanguageSpecificId(string? language, string noLanguageId, strin warningLevel: 0, projectId: projectId, customTags: ImmutableArray.Empty, - properties: ImmutableDictionary.Empty, + properties: ImmutableDictionary.Empty, language: language); } diff --git a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs index d573d86bc93d0..fd2b8b6d8b6b9 100644 --- a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs +++ b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs @@ -33,7 +33,7 @@ internal sealed class DiagnosticData : IEquatable public readonly bool IsEnabledByDefault; public readonly int WarningLevel; public readonly IReadOnlyList CustomTags; - public readonly ImmutableDictionary Properties; + public readonly ImmutableDictionary Properties; public readonly ProjectId? ProjectId; public readonly DiagnosticDataLocation? DataLocation; @@ -65,7 +65,7 @@ public DiagnosticData( bool isEnabledByDefault, int warningLevel, IReadOnlyList customTags, - ImmutableDictionary properties, + ImmutableDictionary properties, ProjectId? projectId, DiagnosticDataLocation? location = null, IReadOnlyCollection? additionalLocations = null, @@ -358,7 +358,7 @@ public static DiagnosticData Create(Diagnostic diagnostic, Document document) { if (additionalProperties == null) { - additionalProperties = ImmutableDictionary.Create(); + additionalProperties = ImmutableDictionary.Create(); } additionalProperties = additionalProperties.Add(nameof(documentPropertiesService.DiagnosticsLspClientName), diagnosticsLspClientName); @@ -380,7 +380,7 @@ private static DiagnosticData Create( OptionSet options, DiagnosticDataLocation? location, IReadOnlyCollection? additionalLocations, - ImmutableDictionary? additionalProperties) + ImmutableDictionary? additionalProperties) { return new DiagnosticData( diagnostic.Id, @@ -403,7 +403,7 @@ private static DiagnosticData Create( isSuppressed: diagnostic.IsSuppressed); } - private static ImmutableDictionary? GetAdditionalProperties(Document document, Diagnostic diagnostic) + private static ImmutableDictionary? GetAdditionalProperties(Document document, Diagnostic diagnostic) { var service = document.GetLanguageService(); return service?.GetAdditionalProperties(diagnostic); diff --git a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticDataSerializer.cs b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticDataSerializer.cs index b2f6b594f2054..1ac81ce3feddb 100644 --- a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticDataSerializer.cs +++ b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticDataSerializer.cs @@ -323,11 +323,11 @@ private static IReadOnlyCollection ReadAdditionalLocatio return result; } - private static ImmutableDictionary GetProperties(ObjectReader reader, int count) + private static ImmutableDictionary GetProperties(ObjectReader reader, int count) { if (count > 0) { - var properties = ImmutableDictionary.CreateBuilder(); + var properties = ImmutableDictionary.CreateBuilder(); for (var i = 0; i < count; i++) { properties.Add(reader.ReadString(), reader.ReadString()); @@ -336,7 +336,7 @@ private static ImmutableDictionary GetProperties(ObjectReader re return properties.ToImmutable(); } - return ImmutableDictionary.Empty; + return ImmutableDictionary.Empty; } private static IReadOnlyList GetCustomTags(ObjectReader reader, int count)