Skip to content

Commit

Permalink
Add some more missing nullable annotations found after building the e…
Browse files Browse the repository at this point in the history
…ntire solution
  • Loading branch information
mavasani committed Nov 8, 2019
1 parent c72761d commit 64aa452
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void AnalyzeCompilationSymbol(CompilationStartAnalysisContext context)
private static void ReportDiagnostic(SymbolAnalysisContext context, INamedTypeSymbol namedTypeSymbol, MissingCtorSignature missingCtorSignature, string constructorSignature)
{
//store MissingCtorSignature enum type into dictionary, to set diagnostic property. This is needed because Diagnostic is immutable
ImmutableDictionary<string, string>.Builder builder = ImmutableDictionary.CreateBuilder<string, string>();
ImmutableDictionary<string, string?>.Builder builder = ImmutableDictionary.CreateBuilder<string, string?>();
builder.Add("Signature", missingCtorSignature.ToString());

//create dignostic and store signature into diagnostic property for fixer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Analyzer.Utilities;
using Analyzer.Utilities.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Imports Analyzer.Utilities
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

Imports Analyzer.Utilities.Extensions
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal CSharpOperationActionsHandler(OperationActionsContext context)
{
}

protected override ITypeSymbol GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation)
protected override ITypeSymbol? GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation)
{
var method = invocationOperation.TargetMethod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.NetCore.CSharp.Analyzers.Runtime
[ExportCodeFixProvider(LanguageNames.CSharp, Name = "CA2237 CodeFix provider"), Shared]
public class CSharpMarkAllNonSerializableFieldsFixer : MarkAllNonSerializableFieldsFixer
{
protected override SyntaxNode GetFieldDeclarationNode(SyntaxNode node)
protected override SyntaxNode? GetFieldDeclarationNode(SyntaxNode node)
{
SyntaxNode fieldNode = node;
while (fieldNode != null && fieldNode.Kind() != SyntaxKind.FieldDeclaration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected override Location GetMethodNameLocation(SyntaxNode invocationNode)
{
Debug.Assert(invocationNode.IsKind(SyntaxKind.InvocationExpression));

var invocation = invocationNode as InvocationExpressionSyntax;
var invocation = (InvocationExpressionSyntax)invocationNode;
if (invocation.Expression.IsKind(SyntaxKind.SimpleMemberAccessExpression))
{
return ((MemberAccessExpressionSyntax)invocation.Expression).Name.GetLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ internal void AnalyzeInvocationOperation(OperationAnalysisContext context)
/// </summary>
/// <param name="invocationOperation">The invocation operation.</param>
/// <returns>The <see cref="ITypeSymbol"/> of the receiver of the extension method.</returns>
protected abstract ITypeSymbol GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation);
protected abstract ITypeSymbol? GetEnumerableCountInvocationTargetType(IInvocationOperation invocationOperation);

/// <summary>
/// Gets the replacement property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public abstract class MarkAllNonSerializableFieldsFixer : CodeFixProvider
{
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(SerializationRulesDiagnosticAnalyzer.RuleCA2235Id);

protected abstract SyntaxNode GetFieldDeclarationNode(SyntaxNode node);
protected abstract SyntaxNode? GetFieldDeclarationNode(SyntaxNode node);

public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
SyntaxNode node = root.FindNode(context.Span);
SyntaxNode fieldNode = GetFieldDeclarationNode(node);
SyntaxNode? fieldNode = GetFieldDeclarationNode(node);
if (fieldNode == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/ReleaseNotesUtil/RuleFileContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace ReleaseNotesUtil
internal class RuleFileContent
{
[DataMember]
public List<RuleInfo> Rules { get; set; }
public List<RuleInfo>? Rules { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Operations;
Expand Down
5 changes: 3 additions & 2 deletions src/Utilities/Compiler/Extensions/CompilationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
// 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.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;

namespace Analyzer.Utilities.Extensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Diagnostics;

namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow.CopyAnalysis
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Diagnostics;
using Analyzer.Utilities.PooledObjects;
using Microsoft.CodeAnalysis.FlowAnalysis.DataFlow;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Diagnostics;

namespace Microsoft.CodeAnalysis.FlowAnalysis.DataFlow
{
Expand Down

0 comments on commit 64aa452

Please sign in to comment.