Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<Compile Include="Rewriters\LocalDeclarationRewriter.cs" />
<Compile Include="Rewriters\MayHaveSideEffectsVisitor.cs" />
<Compile Include="Rewriters\PlaceholderLocalRewriter.cs" />
<Compile Include="SymbolExtensions.cs" />
<Compile Include="Symbols\DisplayClassInstance.cs" />
<Compile Include="Symbols\DisplayClassVariable.cs" />
<Compile Include="Symbols\EEDisplayClassFieldLocalSymbol.cs" />
Expand Down Expand Up @@ -113,4 +114,4 @@
<Import Project="..\..\..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// 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 Microsoft.CodeAnalysis.ExpressionEvaluator;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;

namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator
{
[DkmReportNonFatalWatsonException(ExcludeExceptionType = typeof(NotImplementedException)), DkmContinueCorruptingException]
internal sealed class CSharpFrameDecoder : FrameDecoder
internal sealed class CSharpFrameDecoder : FrameDecoder<CSharpCompilation, MethodSymbol, PEModuleSymbol, TypeSymbol, TypeParameterSymbol>
{
public CSharpFrameDecoder()
: base(CSharpInstructionDecoder.Instance)
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.

using System.Diagnostics;
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
Expand All @@ -9,7 +11,7 @@

namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator
{
internal sealed class CSharpInstructionDecoder : InstructionDecoder<PEMethodSymbol>
internal sealed class CSharpInstructionDecoder : InstructionDecoder<CSharpCompilation, MethodSymbol, PEModuleSymbol, TypeSymbol, TypeParameterSymbol>
{
// This string was not localized in the old EE. We'll keep it that way
// so as not to break consumers who may have been parsing frame names...
Expand All @@ -28,7 +30,7 @@ private CSharpInstructionDecoder()
AddMemberOptions(SymbolDisplayMemberOptions.IncludeParameters).
WithParameterOptions(SymbolDisplayParameterOptions.IncludeType);

internal override void AppendFullName(StringBuilder builder, PEMethodSymbol method)
internal override void AppendFullName(StringBuilder builder, MethodSymbol method)
{
var displayFormat =
((method.MethodKind == MethodKind.PropertyGet) || (method.MethodKind == MethodKind.PropertySet)) ?
Expand Down Expand Up @@ -86,7 +88,28 @@ internal override void AppendFullName(StringBuilder builder, PEMethodSymbol meth
}
}

internal override PEMethodSymbol GetMethod(DkmClrInstructionAddress instructionAddress)
internal override MethodSymbol ConstructMethod(MethodSymbol method, ImmutableArray<TypeParameterSymbol> typeParameters, ImmutableArray<TypeSymbol> typeArguments)
{
var methodArity = method.Arity;
var methodArgumentStartIndex = typeParameters.Length - methodArity;
var typeMap = new TypeMap(
ImmutableArray.Create(typeParameters, 0, methodArgumentStartIndex),
ImmutableArray.Create(typeArguments, 0, methodArgumentStartIndex));
var substitutedType = typeMap.SubstituteNamedType(method.ContainingType);
method = method.AsMember(substitutedType);
if (methodArity > 0)
{
method = method.Construct(ImmutableArray.Create(typeArguments, methodArgumentStartIndex, methodArity));
}
return method;
}

internal override ImmutableArray<TypeParameterSymbol> GetAllTypeParameters(MethodSymbol method)
{
return method.GetAllTypeParameters();
}

internal override CSharpCompilation GetCompilation(DkmClrInstructionAddress instructionAddress)
{
var moduleInstance = instructionAddress.ModuleInstance;
var appDomain = moduleInstance.AppDomain;
Expand All @@ -105,7 +128,18 @@ internal override PEMethodSymbol GetMethod(DkmClrInstructionAddress instructionA
compilation = dataItem.Compilation;
}

return compilation.GetSourceMethod(moduleInstance.Mvid, instructionAddress.MethodId.Token);
return compilation;
}

internal override MethodSymbol GetMethod(CSharpCompilation compilation, DkmClrInstructionAddress instructionAddress)
{
return compilation.GetSourceMethod(instructionAddress.ModuleInstance.Mvid, instructionAddress.MethodId.Token);
}

internal override TypeNameDecoder<PEModuleSymbol, TypeSymbol> GetTypeNameDecoder(CSharpCompilation compilation, MethodSymbol method)
{
Debug.Assert(method is PEMethodSymbol);
return new EETypeNameDecoder(compilation, (PEModuleSymbol)method.ContainingModule);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

using System;
using Microsoft.CodeAnalysis.ExpressionEvaluator;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;

namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator
{
[DkmReportNonFatalWatsonException(ExcludeExceptionType = typeof(NotImplementedException)), DkmContinueCorruptingException]
internal sealed class CSharpLanguageInstructionDecoder : LanguageInstructionDecoder<PEMethodSymbol>
internal sealed class CSharpLanguageInstructionDecoder : LanguageInstructionDecoder<CSharpCompilation, MethodSymbol, PEModuleSymbol, TypeSymbol, TypeParameterSymbol>
{
public CSharpLanguageInstructionDecoder()
: base(CSharpInstructionDecoder.Instance)
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,6 @@ internal CommonPEModuleBuilder CompileAssignment(
return module;
}

private static ImmutableArray<TypeParameterSymbol> GetAllTypeParameters(MethodSymbol method)
{
var builder = ArrayBuilder<TypeParameterSymbol>.GetInstance();
method.ContainingType.GetAllTypeParameters(builder);
builder.AddRange(method.TypeParameters);
return builder.ToImmutableAndFree();
}

private static string GetNextMethodName(ArrayBuilder<MethodSymbol> builder)
{
return string.Format("<>m{0}", builder.Count);
Expand All @@ -270,7 +262,7 @@ internal CommonPEModuleBuilder CompileGetLocals(
DiagnosticBag diagnostics)
{
var objectType = this.Compilation.GetSpecialType(SpecialType.System_Object);
var allTypeParameters = GetAllTypeParameters(_currentFrame);
var allTypeParameters = _currentFrame.GetAllTypeParameters();
var additionalTypes = ArrayBuilder<NamedTypeSymbol>.GetInstance();

EENamedTypeSymbol typeVariablesType = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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 Microsoft.CodeAnalysis.CSharp.Symbols;

namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator
{
internal static class SymbolExtensions
{
internal static ImmutableArray<TypeParameterSymbol> GetAllTypeParameters(this MethodSymbol method)
{
var builder = ArrayBuilder<TypeParameterSymbol>.GetInstance();
method.ContainingType.GetAllTypeParameters(builder);
builder.AddRange(method.TypeParameters);
return builder.ToImmutableAndFree();
}
}
}
Loading