Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
aae813a
Add annotations for most of ISymbol
sharwell Oct 2, 2019
efd08de
Annotate symbol interfaces
sharwell Oct 2, 2019
6624631
Annotate implementations of IAliasSymbol
sharwell Oct 2, 2019
fc97a24
Annotate implementations of IArrayTypeSymbol
sharwell Oct 2, 2019
e0db2e9
Annotate implementations of IAssemblySymbol
sharwell Oct 2, 2019
1ed54dc
Annotate implementations of IDiscardSymbol
sharwell Oct 2, 2019
c3edc2f
Annotate implementations of IDynamicTypeSymbol
sharwell Oct 2, 2019
d8c9e39
Annotate implementations of IErrorTypeSymbol
sharwell Oct 2, 2019
115a9e5
Annotate implementations of IEventSymbol
sharwell Oct 2, 2019
f7cef51
Annotate implementations of IFieldSymbol
sharwell Oct 2, 2019
221e791
Annotate implementations of ILabelSymbol
sharwell Oct 2, 2019
6d9c319
Annotate implementations of ILocalSymbol
sharwell Oct 2, 2019
b811ded
Annotate implementations of IModuleSymbol
sharwell Oct 2, 2019
ef172f8
Annotate implementations of IParameterSymbol
sharwell Oct 2, 2019
a79938a
Annotate implementations of IPreprocessingSymbol
sharwell Oct 2, 2019
4b6c614
Annotate implementations of IRangeVariableSymbol
sharwell Oct 2, 2019
b80e528
Annotate implementations of IPointerTypeSymbol
sharwell Oct 2, 2019
99d5ccd
Annotate implementations of INamespaceSymbol
sharwell Oct 2, 2019
24fa1b4
Annotate implementations of IPropertySymbol
sharwell Oct 2, 2019
f3a3094
Annotate implementations of IAnonymousTypeTemplateSymbolInternal
sharwell Oct 4, 2019
6a32850
Annotate implementations of ITypeParameterSymbol
sharwell Oct 4, 2019
fad8a65
Annotate TypeSymbol
sharwell Oct 4, 2019
bf1ed70
Annotate NamespaceOrTypeSymbol
sharwell Oct 4, 2019
9f8105e
Annotate most of Symbol
sharwell Oct 4, 2019
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
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.CSharp.Symbols;
Expand All @@ -19,7 +21,7 @@ internal partial class Symbol
public static bool IsSymbolAccessible(
Symbol symbol,
NamedTypeSymbol within,
NamedTypeSymbol throughTypeOpt = null)
NamedTypeSymbol? throughTypeOpt = null)
{
if ((object)symbol == null)
{
Expand All @@ -31,7 +33,7 @@ public static bool IsSymbolAccessible(
throw new ArgumentNullException(nameof(within));
}

HashSet<DiagnosticInfo> useSiteDiagnostics = null;
HashSet<DiagnosticInfo>? useSiteDiagnostics = null;
return AccessCheck.IsSymbolAccessible(
symbol,
within,
Expand All @@ -56,7 +58,7 @@ public static bool IsSymbolAccessible(
throw new ArgumentNullException(nameof(within));
}

HashSet<DiagnosticInfo> useSiteDiagnostics = null;
HashSet<DiagnosticInfo>? useSiteDiagnostics = null;
return AccessCheck.IsSymbolAccessible(symbol, within, ref useSiteDiagnostics);
}
}
Expand Down
96 changes: 58 additions & 38 deletions src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs

Large diffs are not rendered by default.

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.Generic;
using System.Collections.Immutable;
using System.Reflection.Metadata;
Expand Down Expand Up @@ -52,16 +54,16 @@ void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
TypeDefinitionHandle Cci.ITypeReference.TypeDef => default(TypeDefinitionHandle);
Cci.PrimitiveTypeCode Cci.ITypeReference.TypeCode => Cci.PrimitiveTypeCode.NotPrimitive;

Cci.ITypeDefinition Cci.ITypeReference.GetResolvedType(EmitContext context) => null;
Cci.IGenericMethodParameterReference Cci.ITypeReference.AsGenericMethodParameterReference => null;
Cci.IGenericTypeInstanceReference Cci.ITypeReference.AsGenericTypeInstanceReference => null;
Cci.IGenericTypeParameterReference Cci.ITypeReference.AsGenericTypeParameterReference => null;
Cci.INamespaceTypeDefinition Cci.ITypeReference.AsNamespaceTypeDefinition(EmitContext context) => null;
Cci.INamespaceTypeReference Cci.ITypeReference.AsNamespaceTypeReference => null;
Cci.INestedTypeDefinition Cci.ITypeReference.AsNestedTypeDefinition(EmitContext context) => null;
Cci.INestedTypeReference Cci.ITypeReference.AsNestedTypeReference => null;
Cci.ISpecializedNestedTypeReference Cci.ITypeReference.AsSpecializedNestedTypeReference => null;
Cci.ITypeDefinition Cci.ITypeReference.AsTypeDefinition(EmitContext context) => null;
Cci.IDefinition Cci.IReference.AsDefinition(EmitContext context) => null;
Cci.ITypeDefinition? Cci.ITypeReference.GetResolvedType(EmitContext context) => null;
Cci.IGenericMethodParameterReference? Cci.ITypeReference.AsGenericMethodParameterReference => null;
Cci.IGenericTypeInstanceReference? Cci.ITypeReference.AsGenericTypeInstanceReference => null;
Cci.IGenericTypeParameterReference? Cci.ITypeReference.AsGenericTypeParameterReference => null;
Cci.INamespaceTypeDefinition? Cci.ITypeReference.AsNamespaceTypeDefinition(EmitContext context) => null;
Cci.INamespaceTypeReference? Cci.ITypeReference.AsNamespaceTypeReference => null;
Cci.INestedTypeDefinition? Cci.ITypeReference.AsNestedTypeDefinition(EmitContext context) => null;
Cci.INestedTypeReference? Cci.ITypeReference.AsNestedTypeReference => null;
Cci.ISpecializedNestedTypeReference? Cci.ITypeReference.AsSpecializedNestedTypeReference => null;
Cci.ITypeDefinition? Cci.ITypeReference.AsTypeDefinition(EmitContext context) => null;
Cci.IDefinition? Cci.IReference.AsDefinition(EmitContext context) => null;
}
}
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.Reflection.Metadata;
using Microsoft.CodeAnalysis.CSharp.Emit;
Expand All @@ -23,7 +25,7 @@ bool Cci.ITypeReference.IsValueType
get { return false; }
}

Cci.ITypeDefinition Cci.ITypeReference.GetResolvedType(EmitContext context)
Cci.ITypeDefinition? Cci.ITypeReference.GetResolvedType(EmitContext context)
{
// dynamic can't be used in mscorlib, so the containing module is never the module being built
return null;
Expand All @@ -39,17 +41,17 @@ TypeDefinitionHandle Cci.ITypeReference.TypeDef
get { return default(TypeDefinitionHandle); }
}

Cci.IGenericMethodParameterReference Cci.ITypeReference.AsGenericMethodParameterReference
Cci.IGenericMethodParameterReference? Cci.ITypeReference.AsGenericMethodParameterReference
{
get { return null; }
}

Cci.IGenericTypeInstanceReference Cci.ITypeReference.AsGenericTypeInstanceReference
Cci.IGenericTypeInstanceReference? Cci.ITypeReference.AsGenericTypeInstanceReference
{
get { return null; }
}

Cci.IGenericTypeParameterReference Cci.ITypeReference.AsGenericTypeParameterReference
Cci.IGenericTypeParameterReference? Cci.ITypeReference.AsGenericTypeParameterReference
{
get { return null; }
}
Expand All @@ -59,28 +61,28 @@ Cci.INamespaceTypeReference Cci.ITypeReference.AsNamespaceTypeReference
get { return this; }
}

Cci.INamespaceTypeDefinition Cci.ITypeReference.AsNamespaceTypeDefinition(EmitContext context)
Cci.INamespaceTypeDefinition? Cci.ITypeReference.AsNamespaceTypeDefinition(EmitContext context)
{
// dynamic can't be used in mscorlib, so the containing module is never the module being built
return null;
}

Cci.INestedTypeReference Cci.ITypeReference.AsNestedTypeReference
Cci.INestedTypeReference? Cci.ITypeReference.AsNestedTypeReference
{
get { return null; }
}

Cci.INestedTypeDefinition Cci.ITypeReference.AsNestedTypeDefinition(EmitContext context)
Cci.INestedTypeDefinition? Cci.ITypeReference.AsNestedTypeDefinition(EmitContext context)
{
return null;
}

Cci.ISpecializedNestedTypeReference Cci.ITypeReference.AsSpecializedNestedTypeReference
Cci.ISpecializedNestedTypeReference? Cci.ITypeReference.AsSpecializedNestedTypeReference
{
get { return null; }
}

Cci.ITypeDefinition Cci.ITypeReference.AsTypeDefinition(EmitContext context)
Cci.ITypeDefinition? Cci.ITypeReference.AsTypeDefinition(EmitContext context)
{
// dynamic can't be used in mscorlib, so the containing module is never the module being built
return null;
Expand All @@ -91,7 +93,7 @@ void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
throw ExceptionUtilities.Unreachable;
}

Cci.IDefinition Cci.IReference.AsDefinition(EmitContext context)
Cci.IDefinition? Cci.IReference.AsDefinition(EmitContext context)
{
// dynamic can't be used in mscorlib, so the containing module is never the module being built
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// 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.Generic;
using System.Diagnostics;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CSharp.Emit;
using Microsoft.CodeAnalysis.Emit;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
Expand All @@ -18,14 +21,14 @@ internal partial class EventSymbol :
CheckDefinitionInvariant();

var addMethod = this.AddMethod;
Debug.Assert((object)addMethod != null);
RoslynDebug.Assert((object?)addMethod != null);
if (addMethod.ShouldInclude(context))
{
yield return addMethod;
}

var removeMethod = this.RemoveMethod;
Debug.Assert((object)removeMethod != null);
RoslynDebug.Assert((object?)removeMethod != null);
if (removeMethod.ShouldInclude(context))
{
yield return removeMethod;
Expand All @@ -37,8 +40,8 @@ Cci.IMethodReference Cci.IEventDefinition.Adder
get
{
CheckDefinitionInvariant();
MethodSymbol addMethod = this.AddMethod;
Debug.Assert((object)addMethod != null);
MethodSymbol? addMethod = this.AddMethod;
RoslynDebug.Assert((object?)addMethod != null);
return addMethod;
}
}
Expand All @@ -48,8 +51,8 @@ Cci.IMethodReference Cci.IEventDefinition.Remover
get
{
CheckDefinitionInvariant();
MethodSymbol removeMethod = this.RemoveMethod;
Debug.Assert((object)removeMethod != null);
MethodSymbol? removeMethod = this.RemoveMethod;
RoslynDebug.Assert((object?)removeMethod != null);
return removeMethod;
}
}
Expand Down Expand Up @@ -81,7 +84,7 @@ bool Cci.IEventDefinition.IsSpecialName
}
}

Cci.IMethodReference Cci.IEventDefinition.Caller
Cci.IMethodReference? Cci.IEventDefinition.Caller
{
get
{
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.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CodeGen;
Expand Down Expand Up @@ -38,12 +40,12 @@ Cci.ITypeReference Cci.IFieldReference.GetType(EmitContext context)
}
}

Cci.IFieldDefinition Cci.IFieldReference.GetResolvedField(EmitContext context)
Cci.IFieldDefinition? Cci.IFieldReference.GetResolvedField(EmitContext context)
{
return ResolvedFieldImpl((PEModuleBuilder)context.Module);
}

private Cci.IFieldDefinition ResolvedFieldImpl(PEModuleBuilder moduleBeingBuilt)
private Cci.IFieldDefinition? ResolvedFieldImpl(PEModuleBuilder moduleBeingBuilt)
{
Debug.Assert(this.IsDefinitionOrDistinct());

Expand All @@ -56,7 +58,7 @@ private Cci.IFieldDefinition ResolvedFieldImpl(PEModuleBuilder moduleBeingBuilt)
return null;
}

Cci.ISpecializedFieldReference Cci.IFieldReference.AsSpecializedFieldReference
Cci.ISpecializedFieldReference? Cci.IFieldReference.AsSpecializedFieldReference
{
get
{
Expand Down Expand Up @@ -101,7 +103,7 @@ void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
}
}

Cci.IDefinition Cci.IReference.AsDefinition(EmitContext context)
Cci.IDefinition? Cci.IReference.AsDefinition(EmitContext context)
{
PEModuleBuilder moduleBeingBuilt = (PEModuleBuilder)context.Module;

Expand All @@ -124,14 +126,14 @@ bool Cci.IFieldReference.IsContextualNamedEntity
}
}

MetadataConstant Cci.IFieldDefinition.GetCompileTimeValue(EmitContext context)
MetadataConstant? Cci.IFieldDefinition.GetCompileTimeValue(EmitContext context)
{
CheckDefinitionInvariant();

return GetMetadataConstantValue(context);
}

internal MetadataConstant GetMetadataConstantValue(EmitContext context)
internal MetadataConstant? GetMetadataConstantValue(EmitContext context)
{
// A constant field of type decimal is not treated as a compile time value in CLR,
// so check if it is a metadata constant, not just a constant to exclude decimals.
Expand Down Expand Up @@ -233,7 +235,7 @@ internal virtual bool IsMarshalledExplicitly
}
}

Cci.IMarshallingInformation Cci.IFieldDefinition.MarshallingInformation
Cci.IMarshallingInformation? Cci.IFieldDefinition.MarshallingInformation
{
get
{
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.CSharp.Symbols
{
internal partial class NamespaceSymbol : Cci.INamespace
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.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
Expand Down Expand Up @@ -56,20 +58,20 @@ ushort Cci.IParameterListEntry.Index
/// <summary>
/// Gets constant value to be stored in metadata Constant table.
/// </summary>
MetadataConstant Cci.IParameterDefinition.GetDefaultValue(EmitContext context)
MetadataConstant? Cci.IParameterDefinition.GetDefaultValue(EmitContext context)
{
CheckDefinitionInvariant();
return this.GetMetadataConstantValue(context);
}

internal MetadataConstant GetMetadataConstantValue(EmitContext context)
internal MetadataConstant? GetMetadataConstantValue(EmitContext context)
{
if (!HasMetadataConstantValue)
{
return null;
}

ConstantValue constant = this.ExplicitDefaultConstantValue;
ConstantValue constant = this.ExplicitDefaultConstantValue!;
TypeSymbol type;
if (constant.SpecialType != SpecialType.None)
{
Expand Down Expand Up @@ -156,7 +158,7 @@ bool Cci.IParameterDefinition.IsOut
}
}

Cci.IMarshallingInformation Cci.IParameterDefinition.MarshallingInformation
Cci.IMarshallingInformation? Cci.IParameterDefinition.MarshallingInformation
{
get
{
Expand Down Expand Up @@ -206,7 +208,7 @@ void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
#endif
}

Cci.IDefinition Cci.IReference.AsDefinition(EmitContext context)
Cci.IDefinition? Cci.IReference.AsDefinition(EmitContext context)
{
Debug.Assert(this.IsDefinitionOrDistinct());

Expand Down
Loading