提交 9f404151 编写于 作者: K Kevin Halverson

Use Guid constructor instead of Guid.Parse...

...for dynamic analysis instrumentation.  Guid.Parse is not available when
targeting .NET 2.0/3.5.
上级 672f22f6
......@@ -33,7 +33,7 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState,
//
// payloadRoot = new T[MaximumMethodDefIndex + 1][];
//
// where T is the type of the payload at each instrumentation point, and MaximumMethodDefIndex is the
// where T is the type of the payload at each instrumentation point, and MaximumMethodDefIndex is the
// index portion of the greatest method definition token in the compilation. This guarantees that any
// method can use the index portion of its own method definition token as an index into the payload array.
......@@ -52,12 +52,12 @@ internal override void GenerateMethodBody(TypeCompilationState compilationState,
}
// Initialize the module version ID (MVID) field. Dynamic instrumentation requires the MVID of the executing module, and this field makes that accessible.
// MVID = Guid.Parse(ModuleVersionIdString);
// MVID = new Guid(ModuleVersionIdString);
body.Add(
factory.Assignment(
factory.ModuleVersionId(),
factory.StaticCall(
WellKnownMember.System_Guid__Parse,
factory.New(
factory.WellKnownMethod(WellKnownMember.System_Guid__ctor),
factory.ModuleVersionIdString())));
}
catch (SyntheticBoundNodeFactory.MissingPredefinedMember missing)
......
......@@ -461,7 +461,7 @@ .maxstack 2
IL_0007: newarr ""bool[]""
IL_000c: stsfld ""bool[][] <PrivateImplementationDetails>.PayloadRoot0""
IL_0011: ldstr ##MVID##
IL_0016: call ""System.Guid System.Guid.Parse(string)""
IL_0016: newobj ""System.Guid..ctor(string)""
IL_001b: stsfld ""System.Guid <PrivateImplementationDetails>.MVID""
IL_0020: ret
}";
......@@ -1944,7 +1944,7 @@ static int TestMain()
foreach (Diagnostic diagnostic in diagnostics)
{
if (diagnostic.Code == (int)ErrorCode.ERR_MissingPredefinedMember &&
diagnostic.Arguments[0].Equals("System.Guid") && diagnostic.Arguments[1].Equals("Parse"))
diagnostic.Arguments[0].Equals("System.Guid") && diagnostic.Arguments[1].Equals(".ctor"))
{
return;
}
......
......@@ -48,7 +48,6 @@ internal enum WellKnownMember
System_CLSCompliantAttribute__ctor,
System_FlagsAttribute__ctor,
System_Guid__ctor,
System_Guid__Parse,
System_Type__GetTypeFromCLSID,
System_Type__GetTypeFromHandle,
......
......@@ -333,14 +333,6 @@ static WellKnownMembers()
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_Void,
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_String,
// System_Guid__Parse
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Guid, // DeclaringTypeId
0, // Arity
1, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Guid,
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_String,
// System_Type__GetTypeFromCLSID
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Type, // DeclaringTypeId
......@@ -2361,7 +2353,7 @@ static WellKnownMembers()
0, // Arity
0, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)WellKnownType.System_Threading_Tasks_Task,
// System_Runtime_CompilerServices_AsyncTaskMethodBuilder_T__Create
(byte)(MemberFlags.Method | MemberFlags.Static), // Flags
(byte)WellKnownType.System_Runtime_CompilerServices_AsyncTaskMethodBuilder_T, // DeclaringTypeId
......@@ -2859,7 +2851,7 @@ static WellKnownMembers()
// System_Runtime_CompilerServices_TupleElementNamesAttribute__ctorTransformNames
(byte)MemberFlags.Constructor, // Flags
(byte)WellKnownType.ExtSentinel, (byte)(WellKnownType.System_Runtime_CompilerServices_TupleElementNamesAttribute // DeclaringTypeId
- WellKnownType.ExtSentinel),
- WellKnownType.ExtSentinel),
0, // Arity
1, // Method Signature
(byte)SignatureTypeCode.TypeHandle, (byte)SpecialType.System_Void,
......@@ -2930,7 +2922,6 @@ static WellKnownMembers()
".ctor", // System_CLSCompliantAttribute__ctor
".ctor", // System_FlagsAttribute__ctor
".ctor", // System_Guid__ctor
"Parse", // System_Guid__Parse
"GetTypeFromCLSID", // System_Type__GetTypeFromCLSID
"GetTypeFromHandle", // System_Type__GetTypeFromHandle
"Missing", // System_Type__Missing
......
......@@ -68,7 +68,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
'
' payloadRoot = New T(MaximumMethodDefIndex)() {}
'
' where T Is the type of the payload at each instrumentation point, and MaximumMethodDefIndex is the
' where T Is the type of the payload at each instrumentation point, and MaximumMethodDefIndex is the
' index portion of the greatest method definition token in the compilation. This guarantees that any
' method can use the index portion of its own method definition token as an index into the payload array.
......@@ -84,14 +84,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Next
' Initialize the module version ID (MVID) field. Dynamic instrumentation requires the MVID of the executing module, and this field makes that accessible.
' MVID = Guid.Parse(ModuleVersionIdString)
' MVID = New Guid(ModuleVersionIdString)
Dim guidParse As MethodSymbol = factory.WellKnownMember(Of MethodSymbol)(WellKnownMember.System_Guid__Parse)
If guidParse IsNot Nothing Then
Dim guidConstructor As MethodSymbol = factory.WellKnownMember(Of MethodSymbol)(WellKnownMember.System_Guid__ctor)
If guidConstructor IsNot Nothing Then
body.Add(
factory.Assignment(
factory.ModuleVersionId(isLValue:=True),
factory.Call(Nothing, guidParse, ImmutableArray.Create(factory.ModuleVersionIdString()))))
factory.[New](guidConstructor, factory.ModuleVersionIdString())))
End If
body.Add(factory.Return())
......
......@@ -1622,7 +1622,7 @@ End Class
Dim diagnostics As ImmutableArray(Of Diagnostic) = CreateCompilation(source).GetEmitDiagnostics(EmitOptions.Default.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage)))
For Each Diagnostic As Diagnostic In diagnostics
If Diagnostic.Code = ERRID.ERR_MissingRuntimeHelper AndAlso Diagnostic.Arguments(0).Equals("System.Guid.Parse") Then
If Diagnostic.Code = ERRID.ERR_MissingRuntimeHelper AndAlso Diagnostic.Arguments(0).Equals("System.Guid..ctor") Then
Return
End If
Next
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册