提交 df875bfc 编写于 作者: V vsadov

Use IsByRefLike attribute

上级 32c82d85
......@@ -320,7 +320,7 @@ private static Conversion ToConversion(OverloadResolutionResult<MethodSymbol> re
//PROTOTYPE(span): generalize to all restricted types or it would be a compat break?
//cannot capture span-like types.
if (!method.IsStatic && methodGroup.Receiver.Type.IsSpanLikeType())
if (!method.IsStatic && methodGroup.Receiver.Type.IsByRefLikeType)
{
return Conversion.NoConversion;
}
......
......@@ -1444,6 +1444,8 @@ private bool IsPartialType()
Debug.Assert(this.CurrentToken.ContextualKind == SyntaxKind.PartialKeyword);
switch (this.PeekToken(1).Kind)
{
case SyntaxKind.RefKeyword:
return this.PeekToken(2).Kind == SyntaxKind.StructKeyword;
case SyntaxKind.StructKeyword:
case SyntaxKind.ClassKeyword:
case SyntaxKind.InterfaceKeyword:
......
......@@ -534,6 +534,12 @@ internal SynthesizedAttributeData SynthesizeTupleNamesAttribute(TypeSymbol type)
return TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_TupleElementNamesAttribute__ctorTransformNames, args);
}
internal SynthesizedAttributeData SynthesizeIsByRefLikeAttribute()
{
// PROTOTYPE(readonlyRefs) it is optional now as it will be generated in the next change
return TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor, isOptionalUse: true);
}
internal static class TupleNamesEncoder
{
public static ImmutableArray<string> Encode(TypeSymbol type)
......
......@@ -129,6 +129,7 @@ private class UncommonProperties
internal ObsoleteAttributeData lazyObsoleteAttributeData = ObsoleteAttributeData.Uninitialized;
internal AttributeUsageInfo lazyAttributeUsageInfo = AttributeUsageInfo.Null;
internal ThreeState lazyContainsExtensionMethods;
internal ThreeState lazyIsByRefLike;
internal string lazyDefaultMemberName;
internal NamedTypeSymbol lazyComImportCoClassType = ErrorTypeSymbol.UnknownResultType;
......@@ -2021,6 +2022,62 @@ internal override bool IsSerializable
get { return (_flags & TypeAttributes.Serializable) != 0; }
}
internal override bool IsByRefLikeType
{
get
{
var uncommon = GetUncommonProperties();
if (uncommon == s_noUncommonProperties)
{
return false;
}
if (!uncommon.lazyIsByRefLike.HasValue())
{
var isByRefLike = ThreeState.False;
if (this.TypeKind == TypeKind.Struct)
{
if (IsWellknownSpans())
{
isByRefLike = ThreeState.True;
}
else
{
var moduleSymbol = this.ContainingPEModule;
var module = moduleSymbol.Module;
isByRefLike = module.HasIsByRefLikeAttribute(_handle).ToThreeState();
}
}
uncommon.lazyIsByRefLike = isByRefLike;
}
return uncommon.lazyIsByRefLike.Value();
}
}
//PROTOTYPE(span): Span and ReadonlySpan should have spanLike marker.
// For now assume that any "System.Span" and "System.ReadOnlySpan" structs
// are span-like
private bool IsWellknownSpans()
{
var originalDef = this.OriginalDefinition;
if (originalDef.Name != "Span" && originalDef.Name != "ReadonlySpan")
{
return false;
}
var ns = originalDef.ContainingSymbol as NamespaceSymbol;
if (ns?.Name != "System")
{
return false;
}
return (object)ns.ContainingNamespace != null;
}
internal override bool HasDeclarativeSecurity
{
get { return (_flags & TypeAttributes.HasSecurity) != 0; }
......
......@@ -670,6 +670,14 @@ public override bool IsStatic
}
}
internal override bool IsByRefLikeType
{
get
{
return (_flags.DeclarationModifiers & DeclarationModifiers.Ref) != 0;
}
}
public override bool IsSealed
{
get
......
......@@ -50,8 +50,7 @@ protected void TypeChecks(TypeSymbol type, DiagnosticBag diagnostics)
{
diagnostics.Add(ErrorCode.ERR_FieldCantHaveVoidType, TypeSyntax.Location);
}
//PROTOTYPE(span): span-like instance fields are allowed in span-like types, for now allow inany struct
else if (type.IsRestrictedType(ignoreSpanLikeTypes: !this.IsStatic && containingType.IsStructType()))
else if (type.IsRestrictedType(ignoreSpanLikeTypes: !this.IsStatic && containingType.IsByRefLikeType))
{
diagnostics.Add(ErrorCode.ERR_FieldCantBeRefAny, TypeSyntax.Location, type);
}
......
......@@ -1097,6 +1097,12 @@ internal override void AddSynthesizedAttributes(ModuleCompilationState compilati
AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_ExtensionAttribute__ctor));
}
if (this.IsByRefLikeType)
{
//PROTOTYPE(span): should also set [Obsolete] Attribute with a known marker
AddSynthesizedAttribute(ref attributes, compilation.SynthesizeIsByRefLikeAttribute());
}
if (this.Indexers.Any())
{
string defaultMemberName = this.Indexers.First().MetadataName; // UNDONE: IndexerNameAttribute
......
......@@ -1308,8 +1308,12 @@ internal override void ForceComplete(SourceLocation locationOpt, CancellationTok
var conversions = new TypeConversions(this.ContainingAssembly.CorLibrary);
this.Type.CheckAllConstraints(conversions, _location, diagnostics);
//PROTOTYPE(span): allow in span-like structs?
if (this.Type.IsRestrictedType(ignoreSpanLikeTypes: !this.IsAutoProperty))
// autoproperties can have span-like types only
// inside a span-like type and when not static
var canReturnSpan = !this.IsAutoProperty ||
(!this.IsStatic && this.ContainingType.IsByRefLikeType);
if (this.Type.IsRestrictedType(ignoreSpanLikeTypes: canReturnSpan))
{
diagnostics.Add(ErrorCode.ERR_FieldCantBeRefAny, this.CSharpSyntaxNode.Type.Location, this.Type);
}
......
......@@ -639,30 +639,10 @@ public virtual NamedTypeSymbol TupleUnderlyingType
/// </remarks>
internal abstract bool IsManagedType { get; }
//PROTOTYPE(span): this will completely change depending on how span-like types are implemented.
// Span<T> and ReadOnlySpan<T> will be special types (currently they are not always)
// Users may be able to define their own Spanlike types, but that is completely NYI
// For now we will be simply looking at "System.Span" and "System.ReadOnlySpan" names
/// <summary>
/// Returns true if the type is a Span/ReadOnlySpan
/// Returns true if the type may contain embedded references
/// </summary>
internal bool IsSpanLikeType()
{
var originalDef = this.OriginalDefinition;
if (originalDef.Name != "Span" && originalDef.Name != "ReadonlySpan")
{
return false;
}
var ns = originalDef.ContainingSymbol as NamespaceSymbol;
if (ns?.Name != "System")
{
return false;
}
return (object)ns.ContainingNamespace != null;
}
internal virtual bool IsByRefLikeType => false;
#region ITypeSymbol Members
......
......@@ -935,7 +935,7 @@ internal static bool IsValidV6SwitchGoverningType(this TypeSymbol type, bool isT
return ignoreSpanLikeTypes?
false:
type.IsSpanLikeType();
type.IsByRefLikeType;
}
public static bool IsIntrinsicType(this TypeSymbol type)
......
......@@ -205,6 +205,11 @@ internal override bool IsSerializable
get { return _underlyingType.IsSerializable; }
}
internal override bool IsByRefLikeType
{
get { return _underlyingType.IsByRefLikeType; }
}
internal override bool HasDeclarativeSecurity
{
get { return _underlyingType.HasDeclarativeSecurity; }
......
......@@ -20,31 +20,59 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
public class SpanStackSafetyTests : CompilingTestBase
{
private static string spanSource = @"
namespace System
{
public struct Span<T>
public ref struct Span<T>
{
public ref T this[int i] => throw null;
public override int GetHashCode() => 1;
}
public struct ReadonlySpan<T>
public ref struct ReadonlySpan<T>
{
public ref readonly T this[int i] => throw null;
public override int GetHashCode() => 2;
}
public ref struct SpanLike<T>
{
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Struct)]
public sealed class IsByRefLikeAttribute: Attribute
{
public IsByRefLikeAttribute(){}
}
}
";
//PROTOTYPE(span): this will be updated when rules for defining span are implemented
// most likely we would just pick the actual binary/corlib where
// span lives.
private static CSharpCompilation CreateCompilationWithMscorlibAndSpan(string text, CSharpCompilationOptions options = null)
{
var reference = CreateCompilationWithMscorlib45(
spanSource,
references: new List<MetadataReference>() { MscorlibRef_v4_0_30316_17626, SystemCoreRef, CSharpRef },
options: TestOptions.ReleaseDll).EmitToImageReference();
var comp = CreateCompilationWithMscorlib45(
text,
references: new List<MetadataReference>() { MscorlibRef_v4_0_30316_17626, SystemCoreRef, CSharpRef, reference},
options: options ?? TestOptions.ReleaseExe);
return comp;
}
private static CSharpCompilation CreateCompilationWithMscorlibAndSpanSrc(string text, CSharpCompilationOptions options = null)
{
var textWitSpan = new string[] { text, spanSource };
var comp = CreateCompilationWithMscorlib45(
textWitSpan,
references: new List<MetadataReference>() { MscorlibRef_v4_0_30316_17626, SystemCoreRef, CSharpRef },
textWitSpan,
references: new List<MetadataReference>() { MscorlibRef_v4_0_30316_17626, SystemCoreRef, CSharpRef },
options: options ?? TestOptions.ReleaseExe);
return comp;
......@@ -62,6 +90,7 @@ static void Main()
{
object x = new Span<int>();
object y = new ReadonlySpan<byte>();
object z = new SpanLike<int>();
}
}
";
......@@ -74,7 +103,24 @@ static void Main()
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new Span<int>()").WithArguments("System.Span<int>", "object").WithLocation(8, 20),
// (9,20): error CS0029: Cannot implicitly convert type 'System.ReadonlySpan<byte>' to 'object'
// object y = new ReadonlySpan<byte>();
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new ReadonlySpan<byte>()").WithArguments("System.ReadonlySpan<byte>", "object").WithLocation(9, 20)
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new ReadonlySpan<byte>()").WithArguments("System.ReadonlySpan<byte>", "object").WithLocation(9, 20),
// (10,20): error CS0029: Cannot implicitly convert type 'System.SpanLike<int>' to 'object'
// object z = new SpanLike<int>();
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new SpanLike<int>()").WithArguments("System.SpanLike<int>", "object")
);
comp = CreateCompilationWithMscorlibAndSpanSrc(text);
comp.VerifyDiagnostics(
// (8,20): error CS0029: Cannot implicitly convert type 'System.Span<int>' to 'object'
// object x = new Span<int>();
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new Span<int>()").WithArguments("System.Span<int>", "object").WithLocation(8, 20),
// (9,20): error CS0029: Cannot implicitly convert type 'System.ReadonlySpan<byte>' to 'object'
// object y = new ReadonlySpan<byte>();
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new ReadonlySpan<byte>()").WithArguments("System.ReadonlySpan<byte>", "object").WithLocation(9, 20),
// (10,20): error CS0029: Cannot implicitly convert type 'System.SpanLike<int>' to 'object'
// object z = new SpanLike<int>();
Diagnostic(ErrorCode.ERR_NoImplicitConv, "new SpanLike<int>()").WithArguments("System.SpanLike<int>", "object")
);
}
......@@ -222,7 +268,7 @@ static void M3(in Span<string> ss)
}
[Fact]
public void Fields()
public void FieldsSpan()
{
var text = @"
using System;
......@@ -236,27 +282,128 @@ static void Main()
public static Span<byte> fs;
public Span<int> fi;
public struct S1
public ref struct S1
{
//PROTOTYPE(span): instance Span fields in structs are ok for now, - until span-like types can be declared
public static Span<byte> fs1;
public Span<int> fi1;
}
public struct S2
{
public static Span<byte> fs2;
public Span<int> fi2;
}
}
";
CSharpCompilation comp = CreateCompilationWithMscorlibAndSpan(text);
comp.VerifyDiagnostics(
// (16,23): error CS0610: Field or property cannot be of type 'Span<byte>'
// (22,16): error CS0610: Field or property cannot be of type 'Span<int>'
// public Span<int> fi1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<int>").WithArguments("System.Span<int>"),
// (21,23): error CS0610: Field or property cannot be of type 'Span<byte>'
// public static Span<byte> fs1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>").WithLocation(16, 23),
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>"),
// (10,19): error CS0610: Field or property cannot be of type 'Span<byte>'
// public static Span<byte> fs;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>").WithLocation(10, 19),
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>"),
// (11,12): error CS0610: Field or property cannot be of type 'Span<int>'
// public Span<int> fi;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<int>").WithArguments("System.Span<int>").WithLocation(11, 12)
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<int>").WithArguments("System.Span<int>"),
// (15,23): error CS0610: Field or property cannot be of type 'Span<byte>'
// public static Span<byte> fs1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>")
);
comp = CreateCompilationWithMscorlibAndSpanSrc(text);
comp.VerifyDiagnostics(
// (22,16): error CS0610: Field or property cannot be of type 'Span<int>'
// public Span<int> fi1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<int>").WithArguments("System.Span<int>"),
// (21,23): error CS0610: Field or property cannot be of type 'Span<byte>'
// public static Span<byte> fs1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>"),
// (10,19): error CS0610: Field or property cannot be of type 'Span<byte>'
// public static Span<byte> fs;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>"),
// (11,12): error CS0610: Field or property cannot be of type 'Span<int>'
// public Span<int> fi;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<int>").WithArguments("System.Span<int>"),
// (15,23): error CS0610: Field or property cannot be of type 'Span<byte>'
// public static Span<byte> fs1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "Span<byte>").WithArguments("System.Span<byte>")
);
}
[Fact]
public void FieldsSpanLike()
{
var text = @"
using System;
public class Program
{
static void Main()
{
}
public static SpanLike<byte> fs;
public SpanLike<int> fi;
public ref struct S1
{
public static SpanLike<byte> fs1;
public SpanLike<int> fi1;
}
public struct S2
{
public static SpanLike<byte> fs2;
public SpanLike<int> fi2;
}
}
";
CSharpCompilation comp = CreateCompilationWithMscorlibAndSpan(text);
comp.VerifyDiagnostics(
// (22,16): error CS0610: Field or property cannot be of type 'SpanLike<int>'
// public SpanLike<int> fi2;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<int>").WithArguments("System.SpanLike<int>").WithLocation(22, 16),
// (21,23): error CS0610: Field or property cannot be of type 'SpanLike<byte>'
// public static SpanLike<byte> fs2;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<byte>").WithArguments("System.SpanLike<byte>").WithLocation(21, 23),
// (10,19): error CS0610: Field or property cannot be of type 'SpanLike<byte>'
// public static SpanLike<byte> fs;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<byte>").WithArguments("System.SpanLike<byte>").WithLocation(10, 19),
// (11,12): error CS0610: Field or property cannot be of type 'SpanLike<int>'
// public SpanLike<int> fi;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<int>").WithArguments("System.SpanLike<int>").WithLocation(11, 12),
// (15,23): error CS0610: Field or property cannot be of type 'SpanLike<byte>'
// public static SpanLike<byte> fs1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<byte>").WithArguments("System.SpanLike<byte>").WithLocation(15, 23)
);
comp = CreateCompilationWithMscorlibAndSpanSrc(text);
comp.VerifyDiagnostics(
// (22,16): error CS0610: Field or property cannot be of type 'SpanLike<int>'
// public SpanLike<int> fi2;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<int>").WithArguments("System.SpanLike<int>").WithLocation(22, 16),
// (21,23): error CS0610: Field or property cannot be of type 'SpanLike<byte>'
// public static SpanLike<byte> fs2;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<byte>").WithArguments("System.SpanLike<byte>").WithLocation(21, 23),
// (10,19): error CS0610: Field or property cannot be of type 'SpanLike<byte>'
// public static SpanLike<byte> fs;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<byte>").WithArguments("System.SpanLike<byte>").WithLocation(10, 19),
// (11,12): error CS0610: Field or property cannot be of type 'SpanLike<int>'
// public SpanLike<int> fi;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<int>").WithArguments("System.SpanLike<int>").WithLocation(11, 12),
// (15,23): error CS0610: Field or property cannot be of type 'SpanLike<byte>'
// public static SpanLike<byte> fs1;
Diagnostic(ErrorCode.ERR_FieldCantBeRefAny, "SpanLike<byte>").WithArguments("System.SpanLike<byte>").WithLocation(15, 23)
);
}
......
......@@ -559,7 +559,8 @@ public void AllWellKnownTypes()
case WellKnownType.System_FormattableString:
case WellKnownType.System_Runtime_CompilerServices_FormattableStringFactory:
case WellKnownType.System_Runtime_CompilerServices_ReadOnlyAttribute:
// Not yet in the platform.
case WellKnownType.System_Runtime_CompilerServices_IsByRefLikeAttribute:
// Not yet in the platform.
case WellKnownType.Microsoft_CodeAnalysis_Runtime_Instrumentation:
// Not always available.
continue;
......@@ -861,6 +862,7 @@ public void AllWellKnownTypeMembers()
continue;
case WellKnownMember.Microsoft_CodeAnalysis_Runtime_Instrumentation__CreatePayload:
case WellKnownMember.System_Runtime_CompilerServices_ReadOnlyAttribute__ctor:
case WellKnownMember.System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor:
// Not always available.
continue;
}
......
......@@ -20,7 +20,7 @@ protected override SyntaxTree ParseTree(string text, CSharpParseOptions options)
}
[Fact]
public void RefStruct001()
public void RefStructSimple()
{
var text = @"
class Program
......@@ -29,6 +29,49 @@ class Program
public ref struct S2{}
}
";
var comp = CreateCompilationWithMscorlib45(text, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7), options: TestOptions.DebugDll);
comp.VerifyDiagnostics(
);
}
[Fact]
public void RefStructErr()
{
var text = @"
class Program
{
ref class S1{}
public ref unsafe struct S2{}
}
";
var comp = CreateCompilationWithMscorlib45(text, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7), options: TestOptions.DebugDll);
comp.VerifyDiagnostics(
// (4,9): error CS1031: Type expected
// ref class S1{}
Diagnostic(ErrorCode.ERR_TypeExpected, "class").WithLocation(4, 9),
// (6,16): error CS1031: Type expected
// public ref unsafe struct S2{}
Diagnostic(ErrorCode.ERR_TypeExpected, "unsafe").WithLocation(6, 16),
// (6,30): error CS0227: Unsafe code may only appear if compiling with /unsafe
// public ref unsafe struct S2{}
Diagnostic(ErrorCode.ERR_IllegalUnsafe, "S2").WithLocation(6, 30)
);
}
[Fact]
public void RefStructPartial()
{
var text = @"
class Program
{
partial ref struct S1{}
partial ref struct S1{}
}
";
var comp = CreateCompilationWithMscorlib45(text, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7), options: TestOptions.DebugDll);
......
......@@ -1024,6 +1024,11 @@ internal bool HasTupleElementNamesAttribute(EntityHandle token, out ImmutableArr
return TryExtractStringArrayValueFromAttribute(info.Handle, out tupleElementNames);
}
internal bool HasIsByRefLikeAttribute(EntityHandle token)
{
return FindTargetAttribute(token, AttributeDescription.IsByRefLikeAttribute).HasValue;
}
internal bool HasDeprecatedOrObsoleteAttribute(EntityHandle token, out ObsoleteAttributeData obsoleteData)
{
AttributeInfo info;
......
......@@ -356,6 +356,7 @@ static AttributeDescription()
private static readonly byte[][] s_signaturesOfObsoleteAttribute = { s_signature_HasThis_Void, s_signature_HasThis_Void_String, s_signature_HasThis_Void_String_Boolean };
private static readonly byte[][] s_signaturesOfDynamicAttribute = { s_signature_HasThis_Void, s_signature_HasThis_Void_SzArray_Boolean };
private static readonly byte[][] s_signaturesOfTupleElementNamesAttribute = { s_signature_HasThis_Void, s_signature_HasThis_Void_SzArray_String };
private static readonly byte[][] s_signaturesOfIsByRefLikeAttribute = { s_signature_HasThis_Void };
private static readonly byte[][] s_signaturesOfDebuggerHiddenAttribute = { s_signature_HasThis_Void };
private static readonly byte[][] s_signaturesOfDebuggerNonUserCodeAttribute = { s_signature_HasThis_Void };
private static readonly byte[][] s_signaturesOfDebuggerStepperBoundaryAttribute = { s_signature_HasThis_Void };
......@@ -485,6 +486,7 @@ static AttributeDescription()
internal static readonly AttributeDescription TypeLibTypeAttribute = new AttributeDescription("System.Runtime.InteropServices", "TypeLibTypeAttribute", s_signaturesOfTypeLibTypeAttribute);
internal static readonly AttributeDescription DynamicAttribute = new AttributeDescription("System.Runtime.CompilerServices", "DynamicAttribute", s_signaturesOfDynamicAttribute);
internal static readonly AttributeDescription TupleElementNamesAttribute = new AttributeDescription("System.Runtime.CompilerServices", "TupleElementNamesAttribute", s_signaturesOfTupleElementNamesAttribute);
internal static readonly AttributeDescription IsByRefLikeAttribute = new AttributeDescription("System.Runtime.CompilerServices", "IsByRefLikeAttribute", s_signaturesOfIsByRefLikeAttribute);
internal static readonly AttributeDescription DebuggerHiddenAttribute = new AttributeDescription("System.Diagnostics", "DebuggerHiddenAttribute", s_signaturesOfDebuggerHiddenAttribute);
internal static readonly AttributeDescription DebuggerNonUserCodeAttribute = new AttributeDescription("System.Diagnostics", "DebuggerNonUserCodeAttribute", s_signaturesOfDebuggerNonUserCodeAttribute);
internal static readonly AttributeDescription DebuggerStepperBoundaryAttribute = new AttributeDescription("System.Diagnostics", "DebuggerStepperBoundaryAttribute", s_signaturesOfDebuggerStepperBoundaryAttribute);
......
......@@ -418,6 +418,8 @@ internal enum WellKnownMember
System_Runtime_CompilerServices_ReadOnlyAttribute__ctor,
System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor,
Count
}
}
......@@ -2885,6 +2885,13 @@ static WellKnownMembers()
0, // Arity
0, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_Void,
// System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor
(byte)(MemberFlags.Constructor), // Flags
(byte)WellKnownType.ExtSentinel, (byte)(WellKnownType.System_Runtime_CompilerServices_IsByRefLikeAttribute - WellKnownType.ExtSentinel), // DeclaringTypeId
0, // Arity
0, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_Void,
};
string[] allNames = new string[(int)WellKnownMember.Count]
......@@ -3244,6 +3251,7 @@ static WellKnownMembers()
"Format", // System_String__Format_IFormatProvider
"CreatePayload", // Microsoft_CodeAnalysis_Runtime_Instrumentation__CreatePayload
".ctor", // System_Runtime_CompilerServices_ReadOnlyAttribute__ctor
".ctor", // System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor
};
s_descriptors = MemberDescriptor.InitializeFromStream(new System.IO.MemoryStream(initializationBytes, writable: false), allNames);
......@@ -3272,6 +3280,7 @@ internal static bool IsSynthesizedAttributeOptional(WellKnownMember attributeMem
case WellKnownMember.System_STAThreadAttribute__ctor:
case WellKnownMember.System_Runtime_CompilerServices_AsyncStateMachineAttribute__ctor:
case WellKnownMember.System_Runtime_CompilerServices_IteratorStateMachineAttribute__ctor:
case WellKnownMember.System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor:
return true;
default:
......
......@@ -265,6 +265,7 @@ internal enum WellKnownType
Microsoft_CodeAnalysis_Runtime_Instrumentation,
System_Runtime_CompilerServices_ReadOnlyAttribute,
System_Runtime_CompilerServices_IsByRefLikeAttribute,
NextAvailable,
}
......@@ -524,6 +525,7 @@ internal static class WellKnownTypes
"Microsoft.CodeAnalysis.Runtime.Instrumentation",
"System.Runtime.CompilerServices.ReadOnlyAttribute",
"System.Runtime.CompilerServices.IsByRefLikeAttribute",
};
private readonly static Dictionary<string, WellKnownType> s_nameToTypeIdMap = new Dictionary<string, WellKnownType>((int)Count);
......
......@@ -508,7 +508,8 @@ End Namespace
' Not a real type
Continue For
Case WellKnownType.Microsoft_CodeAnalysis_Runtime_Instrumentation,
WellKnownType.System_Runtime_CompilerServices_ReadOnlyAttribute
WellKnownType.System_Runtime_CompilerServices_ReadOnlyAttribute,
WellKnownType.System_Runtime_CompilerServices_IsByRefLikeAttribute
' Not always available.
Continue For
End Select
......@@ -544,7 +545,8 @@ End Namespace
' Not a real type
Continue For
Case WellKnownType.Microsoft_CodeAnalysis_Runtime_Instrumentation,
WellKnownType.System_Runtime_CompilerServices_ReadOnlyAttribute
WellKnownType.System_Runtime_CompilerServices_ReadOnlyAttribute,
WellKnownType.System_Runtime_CompilerServices_IsByRefLikeAttribute
' Not always available.
Continue For
End Select
......@@ -583,7 +585,8 @@ End Namespace
' Not available yet, but will be in upcoming release.
Continue For
Case WellKnownMember.Microsoft_CodeAnalysis_Runtime_Instrumentation__CreatePayload,
WellKnownMember.System_Runtime_CompilerServices_ReadOnlyAttribute__ctor
WellKnownMember.System_Runtime_CompilerServices_ReadOnlyAttribute__ctor,
WellKnownMember.System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor
' Not always available.
Continue For
End Select
......@@ -664,7 +667,8 @@ End Namespace
' Not available yet, but will be in upcoming release.
Continue For
Case WellKnownMember.Microsoft_CodeAnalysis_Runtime_Instrumentation__CreatePayload,
WellKnownMember.System_Runtime_CompilerServices_ReadOnlyAttribute__ctor
WellKnownMember.System_Runtime_CompilerServices_ReadOnlyAttribute__ctor,
WellKnownMember.System_Runtime_CompilerServices_IsByRefLikeAttribute__ctor
' Not always available.
Continue For
End Select
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册