Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master to features/static-lambdas #39247

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/Accessibility.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis.Symbols
{
internal abstract class CommonAnonymousTypeManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using System.Reflection.Metadata;
using System.Collections.Immutable;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis
{
Expand All @@ -18,9 +21,9 @@ internal struct AttributeDescription

public AttributeDescription(string @namespace, string name, byte[][] signatures, bool matchIgnoringCase = false)
{
Debug.Assert(@namespace != null);
Debug.Assert(name != null);
Debug.Assert(signatures != null);
RoslynDebug.Assert(@namespace != null);
RoslynDebug.Assert(name != null);
RoslynDebug.Assert(signatures != null);

this.Namespace = @namespace;
this.Name = name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Microsoft.CodeAnalysis.Collections;
Expand Down Expand Up @@ -167,11 +169,11 @@ internal object GetValidTargetsErrorArgument()

private struct ValidTargetsStringLocalizableErrorArgument : IFormattable
{
private readonly string[] _targetResourceIds;
private readonly string[]? _targetResourceIds;

internal ValidTargetsStringLocalizableErrorArgument(string[] targetResourceIds)
{
Debug.Assert(targetResourceIds != null);
RoslynDebug.Assert(targetResourceIds != null);
_targetResourceIds = targetResourceIds;
}

Expand All @@ -180,7 +182,7 @@ public override string ToString()
return ToString(null, null);
}

public string ToString(string format, IFormatProvider formatProvider)
public string ToString(string? format, IFormatProvider? formatProvider)
{
var builder = PooledStringBuilder.GetInstance();
var culture = formatProvider as System.Globalization.CultureInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis
{
internal static class CommonAttributeDataExtensions
{
public static bool TryGetGuidAttributeValue(this AttributeData attrData, out string guidString)
public static bool TryGetGuidAttributeValue(this AttributeData attrData, out string? guidString)
{
if (attrData.CommonConstructorArguments.Length == 1)
{
object value = attrData.CommonConstructorArguments[0].Value;
object? value = attrData.CommonConstructorArguments[0].Value;

if (value == null || value is string)
{
guidString = (string)value;
guidString = (string?)value;
return true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/CustomModifier.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using Microsoft.CodeAnalysis.Emit;

Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/CustomModifiersTuple.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System.Collections.Immutable;

namespace Microsoft.CodeAnalysis
Expand Down
21 changes: 13 additions & 8 deletions src/Compilers/Core/Portable/Symbols/ISymbol.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Threading;
Expand All @@ -18,7 +21,7 @@ namespace Microsoft.CodeAnalysis
/// change it in the future.
/// </remarks>
[InternalImplementationOnly]
public interface ISymbol : IEquatable<ISymbol>
public interface ISymbol : IEquatable<ISymbol?>
{
/// <summary>
/// Gets the <see cref="SymbolKind"/> indicating what kind of symbol it is.
Expand Down Expand Up @@ -55,6 +58,7 @@ public interface ISymbol : IEquatable<ISymbol>
/// </summary>
string MetadataName { get; }

#nullable disable // Skipped for now https://github.com/dotnet/roslyn/issues/39166
/// <summary>
/// Gets the <see cref="ISymbol"/> for the immediately containing symbol.
/// </summary>
Expand Down Expand Up @@ -83,6 +87,7 @@ public interface ISymbol : IEquatable<ISymbol>
/// symbol isn't contained in a namespace.
/// </summary>
INamespaceSymbol ContainingNamespace { get; }
#nullable enable

/// <summary>
/// Gets a value indicating whether the symbol is the original definition. Returns false
Expand Down Expand Up @@ -201,7 +206,7 @@ public interface ISymbol : IEquatable<ISymbol>
/// Returns the Documentation Comment ID for the symbol, or null if the symbol doesn't
/// support documentation comments.
/// </summary>
string GetDocumentationCommentId();
string? GetDocumentationCommentId();

/// <summary>
/// Gets the XML (as text) for the comment associated with the symbol.
Expand All @@ -210,14 +215,14 @@ public interface ISymbol : IEquatable<ISymbol>
/// <param name="expandIncludes">Optionally, expand &lt;include&gt; elements. No impact on non-source documentation comments.</param>
/// <param name="cancellationToken">Token allowing cancellation of request.</param>
/// <returns>The XML that would be written to the documentation file for the symbol.</returns>
string GetDocumentationCommentXml(CultureInfo preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default(CancellationToken));
string? GetDocumentationCommentXml(CultureInfo? preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Converts the symbol to a string representation.
/// </summary>
/// <param name="format">Format or null for the default.</param>
/// <returns>A formatted string representation of the symbol.</returns>
string ToDisplayString(SymbolDisplayFormat format = null);
string ToDisplayString(SymbolDisplayFormat? format = null);

/// <summary>
/// Convert a symbol to an array of string parts, each of which has a kind. Useful for
Expand All @@ -226,7 +231,7 @@ public interface ISymbol : IEquatable<ISymbol>
/// <param name="format">Formatting rules - null implies
/// SymbolDisplayFormat.ErrorMessageFormat.</param>
/// <returns>A read-only array of string parts.</returns>
ImmutableArray<SymbolDisplayPart> ToDisplayParts(SymbolDisplayFormat format = null);
ImmutableArray<SymbolDisplayPart> ToDisplayParts(SymbolDisplayFormat? format = null);

/// <summary>
/// Convert a symbol to a string that can be displayed to the user. May be tailored to a
Expand All @@ -241,7 +246,7 @@ public interface ISymbol : IEquatable<ISymbol>
string ToMinimalDisplayString(
SemanticModel semanticModel,
int position,
SymbolDisplayFormat format = null);
SymbolDisplayFormat? format = null);

/// <summary>
/// Convert a symbol to an array of string parts, each of which has a kind. May be tailored
Expand All @@ -256,7 +261,7 @@ string ToMinimalDisplayString(
ImmutableArray<SymbolDisplayPart> ToMinimalDisplayParts(
SemanticModel semanticModel,
int position,
SymbolDisplayFormat format = null);
SymbolDisplayFormat? format = null);

/// <summary>
/// Indicates that this symbol uses metadata that cannot be supported by the language.
Expand Down Expand Up @@ -295,6 +300,6 @@ ImmutableArray<SymbolDisplayPart> ToMinimalDisplayParts(
/// <param name="other">The other symbol to compare against</param>
/// <param name="equalityComparer">The <see cref="SymbolEqualityComparer"/> to use when comparing symbols</param>
/// <returns>True if the symbols are equivalent.</returns>
bool Equals(ISymbol other, SymbolEqualityComparer equalityComparer);
bool Equals([NotNullWhen(returnValue: true)] ISymbol? other, SymbolEqualityComparer equalityComparer);
}
}
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/LanguageNames.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/ManagedKind.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;

namespace Microsoft.CodeAnalysis
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/MethodKind.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/NamespaceKind.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/Symbols/NullabilityInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Roslyn.Utilities;
Expand Down Expand Up @@ -31,7 +33,7 @@ internal NullabilityInfo(NullableAnnotation annotation, NullableFlowState flowSt

private string GetDebuggerDisplay() => $"{{Annotation: {Annotation}, Flow State: {FlowState}}}";

public override bool Equals(object other) =>
public override bool Equals(object? other) =>
other is NullabilityInfo info && Equals(info);

public override int GetHashCode() =>
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/NullableAnnotation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/NullableFlowState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis
{
/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions src/Compilers/Core/Portable/Symbols/PlatformInvokeInformation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System.Reflection;
using System.Runtime.InteropServices;
using Roslyn.Utilities;
Expand All @@ -11,11 +13,11 @@ namespace Microsoft.CodeAnalysis
/// </summary>
public sealed class DllImportData : Cci.IPlatformInvokeInformation
{
private readonly string _moduleName;
private readonly string _entryPointName; // null if unspecified, the name of the target method should be used
private readonly string? _moduleName;
private readonly string? _entryPointName; // null if unspecified, the name of the target method should be used
private readonly MethodImportAttributes _flags;

internal DllImportData(string moduleName, string entryPointName, MethodImportAttributes flags)
internal DllImportData(string? moduleName, string? entryPointName, MethodImportAttributes flags)
{
_moduleName = moduleName;
_entryPointName = entryPointName;
Expand All @@ -25,15 +27,15 @@ internal DllImportData(string moduleName, string entryPointName, MethodImportAtt
/// <summary>
/// Module name. Null if value specified in the attribute is not valid.
/// </summary>
public string ModuleName
public string? ModuleName
{
get { return _moduleName; }
}

/// <summary>
/// Name of the native entry point or null if not specified (the effective name is the same as the name of the target method).
/// </summary>
public string EntryPointName
public string? EntryPointName
{
get { return _entryPointName; }
}
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/RefKind.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using Roslyn.Utilities;

Expand Down
10 changes: 6 additions & 4 deletions src/Compilers/Core/Portable/Symbols/SymbolEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Symbols;
Expand All @@ -9,7 +11,7 @@ namespace Microsoft.CodeAnalysis
/// <summary>
/// Allows for the comparison of two <see cref="ISymbol"/> instances
/// </summary>
public sealed class SymbolEqualityComparer : IEqualityComparer<ISymbol>
public sealed class SymbolEqualityComparer : IEqualityComparer<ISymbol?>
{
/// <summary>
/// Compares two <see cref="ISymbol"/> instances based on the default comparison rules, equivalent to calling <see cref="IEquatable{ISymbol}.Equals(ISymbol)"/>
Expand Down Expand Up @@ -37,7 +39,7 @@ private SymbolEqualityComparer(TypeCompareKind compareKind)
/// <param name="x">The first symbol to compare</param>
/// <param name="y">The second symbol to compare</param>
/// <returns>True if the symbols are equivalent</returns>
public bool Equals(ISymbol x, ISymbol y)
public bool Equals(ISymbol? x, ISymbol? y)
{
if (x is null)
{
Expand All @@ -53,11 +55,11 @@ public bool Equals(ISymbol x, ISymbol y)
}
else
{
return x.Equals((object)y);
return x.Equals((object?)y);
}
}

public int GetHashCode(ISymbol obj)
public int GetHashCode(ISymbol? obj)
{
return obj?.GetHashCode() ?? 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/SymbolKind.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/Symbols/SymbolKindExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/Symbols/SymbolVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis
{
public abstract class SymbolVisitor
{
public virtual void Visit(ISymbol symbol)
public virtual void Visit(ISymbol? symbol)
{
symbol?.Accept(this);
}
Expand Down
Loading