提交 eb4dc6c2 编写于 作者: T Tomáš Matoušek 提交者: GitHub

Merge pull request #19468 from tmat/Cleanup2

Adds internal Compiler.CommonWithMetadataImportOptions and removes SymUnmanagedExtensions
......@@ -422,7 +422,7 @@ internal CSharpCompilationOptions WithDebugPlusMode(bool debugPlusMode)
return new CSharpCompilationOptions(this) { DebugPlusMode_internal_protected_set = debugPlusMode };
}
internal CSharpCompilationOptions WithMetadataImportOptions(MetadataImportOptions value)
internal new CSharpCompilationOptions WithMetadataImportOptions(MetadataImportOptions value)
{
if (value == this.MetadataImportOptions)
{
......@@ -520,6 +520,9 @@ public new CSharpCompilationOptions WithStrongNameProvider(StrongNameProvider pr
protected override CompilationOptions CommonWithStrongNameProvider(StrongNameProvider provider) =>
WithStrongNameProvider(provider);
internal override CompilationOptions CommonWithMetadataImportOptions(MetadataImportOptions value) =>
WithMetadataImportOptions(value);
[Obsolete]
protected override CompilationOptions CommonWithFeatures(ImmutableArray<string> features)
{
......
......@@ -502,6 +502,8 @@ public CompilationOptions WithOverflowChecks(bool checkOverflow)
return CommonWithCheckOverflow(checkOverflow);
}
internal CompilationOptions WithMetadataImportOptions(MetadataImportOptions value) => CommonWithMetadataImportOptions(value);
protected abstract CompilationOptions CommonWithConcurrentBuild(bool concurrent);
protected abstract CompilationOptions CommonWithDeterministic(bool deterministic);
protected abstract CompilationOptions CommonWithOutputKind(OutputKind kind);
......@@ -525,6 +527,7 @@ public CompilationOptions WithOverflowChecks(bool checkOverflow)
protected abstract CompilationOptions CommonWithCryptoPublicKey(ImmutableArray<byte> cryptoPublicKey);
protected abstract CompilationOptions CommonWithDelaySign(bool? delaySign);
protected abstract CompilationOptions CommonWithCheckOverflow(bool checkOverflow);
internal abstract CompilationOptions CommonWithMetadataImportOptions(MetadataImportOptions value);
[Obsolete]
protected abstract CompilationOptions CommonWithFeatures(ImmutableArray<string> features);
......
......@@ -738,6 +738,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return Me.WithReportSuppressedDiagnostics(reportSuppressedDiagnostics)
End Function
Friend Overrides Function CommonWithMetadataImportOptions(value As MetadataImportOptions) As CompilationOptions
Return WithMetadataImportOptions(value)
End Function
<Obsolete>
Protected Overrides Function CommonWithFeatures(features As ImmutableArray(Of String)) As CompilationOptions
Throw New NotImplementedException()
......@@ -807,7 +811,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return New VisualBasicCompilationOptions(Me) With {.OptimizationLevel = value}
End Function
Friend Function WithMetadataImportOptions(value As MetadataImportOptions) As VisualBasicCompilationOptions
Friend Shadows Function WithMetadataImportOptions(value As MetadataImportOptions) As VisualBasicCompilationOptions
If value = Me.MetadataImportOptions Then
Return Me
End If
......
......@@ -3729,7 +3729,7 @@ static void Main()
(int bufferLength, out int count, byte[] name) =>
{
count = 0;
return DiaSymReader.SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
});
var debugInfo = new MethodDebugInfoBytes.Builder(constants: new[] { badConst }).Build();
var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
......
......@@ -19,9 +19,6 @@
<Compile Include="..\..\..\..\Test\PdbUtilities\Shared\DateTimeUtilities.cs">
<Link>Shared\DateTimeUtilities.cs</Link>
</Compile>
<Compile Include="..\..\..\..\Test\PdbUtilities\Shared\SymUnmanagedReaderExtensions.cs">
<Link>Shared\SymUnmanagedReaderExtensions.cs</Link>
</Compile>
<Compile Include="AssemblyReaders.cs" />
<Compile Include="AssemblyReference.cs" />
<Compile Include="CustomTypeInfo.cs" />
......
......@@ -6,8 +6,9 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
using Microsoft.CodeAnalysis.Debugging;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Debugging;
using Microsoft.DiaSymReader;
using Roslyn.Utilities;
......@@ -48,6 +49,11 @@ public override int GetHashCode()
}
}
internal const int S_OK = 0x0;
internal const int E_FAIL = unchecked((int)0x80004005);
internal const int E_NOTIMPL = unchecked((int)0x80004001);
private static readonly IntPtr s_ignoreIErrorInfo = new IntPtr(-1);
public unsafe static MethodDebugInfo<TTypeSymbol, TLocalSymbol> ReadMethodDebugInfo(
ISymUnmanagedReader3 symReader,
EESymbolProvider<TTypeSymbol, TLocalSymbol> symbolProviderOpt, // TODO: only null in DTEE case where we looking for default namesapace
......@@ -65,9 +71,9 @@ public override int GetHashCode()
if (symReader is ISymUnmanagedReader5 symReader5)
{
int hr = symReader5.GetPortableDebugMetadataByVersion(methodVersion, out byte* metadata, out int size);
SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr);
ThrowExceptionForHR(hr);
if (hr == 0)
if (hr == S_OK)
{
var mdReader = new MetadataReader(metadata, size);
try
......@@ -133,7 +139,7 @@ public override int GetHashCode()
ImmutableDictionary<int, ImmutableArray<string>> tupleLocalMap = null;
ImmutableDictionary<LocalNameAndScope, ImmutableArray<string>> tupleLocalConstantMap = null;
byte[] customDebugInfo = symReader.GetCustomDebugInfoBytes(methodToken, methodVersion);
byte[] customDebugInfo = GetCustomDebugInfoBytes(symReader, methodToken, methodVersion);
if (customDebugInfo != null)
{
if (!isVisualBasicMethod)
......@@ -189,6 +195,33 @@ public override int GetHashCode()
}
}
private static void ThrowExceptionForHR(int hr)
{
// E_FAIL indicates "no info".
// E_NOTIMPL indicates a lack of ISymUnmanagedReader support (in a particular implementation).
if (hr < 0 && hr != E_FAIL && hr != E_NOTIMPL)
{
Marshal.ThrowExceptionForHR(hr, s_ignoreIErrorInfo);
}
}
/// <summary>
/// Get the blob of binary custom debug info for a given method.
/// </summary>
private static byte[] GetCustomDebugInfoBytes(ISymUnmanagedReader3 reader, int methodToken, int methodVersion)
{
try
{
return reader.GetCustomDebugInfo(methodToken, methodVersion);
}
catch (ArgumentOutOfRangeException)
{
// Sometimes the debugger returns the HRESULT for ArgumentOutOfRangeException, rather than E_FAIL,
// for methods without custom debug info (https://github.com/dotnet/roslyn/issues/4138).
return null;
}
}
/// <summary>
/// Get the (unprocessed) import strings for a given method.
/// </summary>
......@@ -255,7 +288,7 @@ private static ImmutableArray<string> GetImportStrings(ISymUnmanagedReader reade
var importStringGroups = CustomDebugInfoReader.GetCSharpGroupedImportStrings(
methodToken,
KeyValuePair.Create(reader, methodVersion),
getMethodCustomDebugInfo: (token, arg) => arg.Key.GetCustomDebugInfoBytes(token, arg.Value),
getMethodCustomDebugInfo: (token, arg) => GetCustomDebugInfoBytes(arg.Key, token, arg.Value),
getMethodImportStrings: (token, arg) => GetImportStrings(arg.Key, token, arg.Value),
externAliasStrings: out externAliasStrings);
......
......@@ -42,7 +42,7 @@ internal static void GetAllScopes(this ISymUnmanagedMethod method, ArrayBuilder<
{
var scope = stack.Pop();
allScopes.Add(scope);
if (offset >= 0 && scope.IsInScope(offset, isScopeEndInclusive))
if (offset >= 0 && IsInScope(scope, offset, isScopeEndInclusive))
{
containingScopes.Add(scope);
}
......@@ -56,6 +56,21 @@ internal static void GetAllScopes(this ISymUnmanagedMethod method, ArrayBuilder<
stack.Free();
}
private static bool IsInScope(ISymUnmanagedScope scope, int offset, bool isEndInclusive)
{
int startOffset = scope.GetStartOffset();
if (offset < startOffset)
{
return false;
}
int endOffset = scope.GetEndOffset();
// In PDBs emitted by VB the end offset is inclusive,
// in PDBs emitted by C# the end offset is exclusive.
return isEndInclusive ? offset <= endOffset : offset < endOffset;
}
/// <summary>
/// Translates the value of a constant returned by <see cref="ISymUnmanagedConstant.GetValue(out object)"/> to a <see cref="ConstantValue"/>.
/// </summary>
......
......@@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices.ComTypes;
using Microsoft.DiaSymReader;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
......@@ -32,12 +33,12 @@ public int GetMethodByVersion(int methodToken, int version, out ISymUnmanagedMet
if (!_methodDebugInfoMap.TryGetValue(methodToken, out info))
{
retVal = null;
return SymUnmanagedReaderExtensions.E_FAIL;
return HResult.E_FAIL;
}
Assert.NotNull(info);
retVal = info.Method;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetSymAttribute(int methodToken, string name, int bufferLength, out int count, byte[] customDebugInformation)
......@@ -58,12 +59,12 @@ public int GetSymAttributeByVersion(int methodToken, int version, string name, i
if (!_methodDebugInfoMap.TryGetValue(methodToken, out info))
{
count = 0;
return SymUnmanagedReaderExtensions.S_FALSE; // This is a guess. We're not consuming it, so it doesn't really matter.
return HResult.S_FALSE; // This is a guess. We're not consuming it, so it doesn't really matter.
}
Assert.NotNull(info);
info.Bytes.TwoPhaseCopy(bufferLength, out count, customDebugInformation);
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetDocument(string url, Guid language, Guid languageVendor, Guid documentType, out ISymUnmanagedDocument document)
......@@ -169,13 +170,13 @@ public MockSymUnmanagedMethod(ISymUnmanagedScope rootScope)
int ISymUnmanagedMethod.GetRootScope(out ISymUnmanagedScope retVal)
{
retVal = _rootScope;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
int ISymUnmanagedMethod.GetSequencePointCount(out int retVal)
{
retVal = 1;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
int ISymUnmanagedMethod.GetSequencePoints(int cPoints, out int pcPoints, int[] offsets, ISymUnmanagedDocument[] documents, int[] lines, int[] columns, int[] endLines, int[] endColumns)
......@@ -187,7 +188,7 @@ int ISymUnmanagedMethod.GetSequencePoints(int cPoints, out int pcPoints, int[] o
columns[0] = 0;
endLines[0] = 0;
endColumns[0] = 0;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
int ISymUnmanagedMethod.GetNamespace(out ISymUnmanagedNamespace retVal)
......@@ -246,37 +247,37 @@ public MockSymUnmanagedScope(ImmutableArray<ISymUnmanagedScope> children, Immuta
public int GetChildren(int numDesired, out int numRead, ISymUnmanagedScope[] buffer)
{
_children.TwoPhaseCopy(numDesired, out numRead, buffer);
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetNamespaces(int numDesired, out int numRead, ISymUnmanagedNamespace[] buffer)
{
_namespaces.TwoPhaseCopy(numDesired, out numRead, buffer);
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetStartOffset(out int pRetVal)
{
pRetVal = _startOffset;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetEndOffset(out int pRetVal)
{
pRetVal = _endOffset;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetLocalCount(out int pRetVal)
{
pRetVal = 0;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetLocals(int cLocals, out int pcLocals, ISymUnmanagedVariable[] locals)
{
pcLocals = 0;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetMethod(out ISymUnmanagedMethod pRetVal)
......@@ -292,7 +293,7 @@ public int GetParent(out ISymUnmanagedScope pRetVal)
public int GetConstantCount(out int pRetVal)
{
pRetVal = _constants.Length;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
public int GetConstants(int cConstants, out int pcConstants, ISymUnmanagedConstant[] constants)
......@@ -302,7 +303,7 @@ public int GetConstants(int cConstants, out int pcConstants, ISymUnmanagedConsta
{
Array.Copy(_constants, constants, constants.Length);
}
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
}
......@@ -361,7 +362,7 @@ int ISymUnmanagedConstant.GetName(int bufferLength, out int count, char[] name)
{
name[i] = _name[i];
}
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
int ISymUnmanagedConstant.GetSignature(int bufferLength, out int count, byte[] signature)
......@@ -372,7 +373,7 @@ int ISymUnmanagedConstant.GetSignature(int bufferLength, out int count, byte[] s
int ISymUnmanagedConstant.GetValue(out object value)
{
value = _value;
return SymUnmanagedReaderExtensions.S_OK;
return HResult.S_OK;
}
}
......
// 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.SymbolStore;
using System.Runtime.InteropServices.ComTypes;
using Microsoft.DiaSymReader;
using Roslyn.Test.Utilities;
namespace Microsoft.CodeAnalysis.ExpressionEvaluator.UnitTests
{
......@@ -16,131 +16,131 @@ internal sealed class NotImplementedSymUnmanagedReader : ISymUnmanagedReader, IS
public int GetDocument(string url, Guid language, Guid languageVendor, Guid documentType, out ISymUnmanagedDocument retVal)
{
retVal = null;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetDocuments(int cDocs, out int pcDocs, ISymUnmanagedDocument[] pDocs)
{
pcDocs = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetDocumentVersion(ISymUnmanagedDocument pDoc, out int version, out bool pbCurrent)
{
version = 0;
pbCurrent = false;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetGlobalVariables(int cVars, out int pcVars, ISymUnmanagedVariable[] vars)
{
pcVars = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethod(int methodToken, out ISymUnmanagedMethod retVal)
{
retVal = null;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethodByVersion(int methodToken, int version, out ISymUnmanagedMethod retVal)
{
retVal = null;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethodByVersionPreRemap(int methodToken, int version, out ISymUnmanagedMethod retVal)
{
retVal = null;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethodFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, out ISymUnmanagedMethod retVal)
{
retVal = null;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethodsFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, int cMethod, out int pcMethod, ISymUnmanagedMethod[] pRetVal)
{
pcMethod = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethodsInDocument(ISymUnmanagedDocument document, int cMethod, out int pcMethod, ISymUnmanagedMethod[] methods)
{
pcMethod = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetMethodVersion(ISymUnmanagedMethod pMethod, out int version)
{
version = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetNamespaces(int cNameSpaces, out int pcNameSpaces, ISymUnmanagedNamespace[] namespaces)
{
pcNameSpaces = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetSymAttribute(int parent, string name, int sizeBuffer, out int lengthBuffer, byte[] buffer)
{
lengthBuffer = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetSymAttributeByVersion(int methodToken, int version, string name, int bufferLength, out int count, byte[] customDebugInformation)
{
count = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetSymAttributeByVersionPreRemap(int methodToken, int version, string name, int bufferLength, out int count, byte[] customDebugInformation)
{
count = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetSymAttributePreRemap(int parent, string name, int sizeBuffer, out int lengthBuffer, byte[] buffer)
{
lengthBuffer = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetSymbolStoreFileName(int cchName, out int pcchName, char[] szName)
{
pcchName = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetUserEntryPoint(out int EntryPoint)
{
EntryPoint = default(int);
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int GetVariables(int parent, int cVars, out int pcVars, ISymUnmanagedVariable[] vars)
{
pcVars = 0;
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int Initialize(object importer, string filename, string searchPath, IStream stream)
{
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int ReplaceSymbolStore(string filename, IStream stream)
{
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
public int UpdateSymbolStore(string filename, IStream stream)
{
return SymUnmanagedReaderExtensions.E_NOTIMPL;
return HResult.E_NOTIMPL;
}
}
}
......@@ -3187,7 +3187,7 @@ End Module"
1,
Function(bufferLength As Integer, ByRef count As Integer, name() As Byte)
count = 0
Return DiaSymReader.SymUnmanagedReaderExtensions.E_NOTIMPL
Return HResult.E_NOTIMPL
End Function)
Dim debugInfo = New MethodDebugInfoBytes.Builder(constants:={badConst}).Build()
......
......@@ -12,7 +12,7 @@ public static class CustomDebugInfoUtilities
{
public static byte[] GetCustomDebugInfoBytes(ISymUnmanagedReader3 reader, MethodDefinitionHandle handle, int methodVersion)
{
return reader.GetCustomDebugInfoBytes(MetadataTokens.GetToken(handle), methodVersion);
return reader.GetCustomDebugInfo(MetadataTokens.GetToken(handle), methodVersion);
}
public static ImmutableArray<byte> GetEditAndContinueLocalSlotMapRecord(byte[] customDebugInfoBlob)
......
......@@ -35,7 +35,6 @@
<Compile Include="Shared\DateTimeUtilities.cs" />
<Compile Include="Shared\DummyMetadataImport.cs" />
<Compile Include="Shared\StringUtilities.cs" />
<Compile Include="Shared\SymUnmanagedReaderExtensions.cs" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleToTest Include="Roslyn.Compilers.UnitTests" />
......
// 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.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
namespace Microsoft.DiaSymReader
{
internal static class SymUnmanagedReaderExtensions
{
internal const int S_OK = 0x0;
internal const int S_FALSE = 0x1;
internal const int E_FAIL = unchecked((int)0x80004005);
internal const int E_NOTIMPL = unchecked((int)0x80004001);
private static readonly IntPtr s_ignoreIErrorInfo = new IntPtr(-1);
/// <summary>
/// Get the blob of binary custom debug info for a given method.
/// </summary>
public static byte[] GetCustomDebugInfoBytes(this ISymUnmanagedReader3 reader, int methodToken, int methodVersion)
{
try
{
return reader.GetCustomDebugInfo(methodToken, methodVersion);
}
catch (ArgumentOutOfRangeException)
{
// Sometimes the debugger returns the HRESULT for ArgumentOutOfRangeException, rather than E_FAIL,
// for methods without custom debug info (https://github.com/dotnet/roslyn/issues/4138).
return null;
}
}
internal static ImmutableArray<string> GetLocalVariableSlots(this ISymUnmanagedMethod method)
{
var builder = ImmutableArray.CreateBuilder<string>();
ISymUnmanagedScope rootScope = method.GetRootScope();
ForEachLocalVariableRecursive(rootScope, offset: -1, isScopeEndInclusive: false, action: local =>
{
int slot = local.GetSlot();
while (builder.Count <= slot)
{
builder.Add(null);
}
var name = local.GetName();
builder[slot] = name;
});
return builder.ToImmutable();
}
private static void ForEachLocalVariableRecursive(
ISymUnmanagedScope scope,
int offset,
bool isScopeEndInclusive,
Action<ISymUnmanagedVariable> action)
{
Debug.Assert(offset < 0 || scope.IsInScope(offset, isScopeEndInclusive));
// apply action on locals of the current scope:
foreach (var local in scope.GetLocals())
{
action(local);
}
// recurse:
foreach (var child in scope.GetChildren())
{
if (offset < 0 || child.IsInScope(offset, isScopeEndInclusive))
{
ForEachLocalVariableRecursive(child, offset, isScopeEndInclusive, action);
if (offset >= 0)
{
return;
}
}
}
}
internal static bool IsInScope(this ISymUnmanagedScope scope, int offset, bool isEndInclusive)
{
int startOffset = scope.GetStartOffset();
if (offset < startOffset)
{
return false;
}
int endOffset = scope.GetEndOffset();
// In PDBs emitted by VB the end offset is inclusive,
// in PDBs emitted by C# the end offset is exclusive.
return isEndInclusive ? offset <= endOffset : offset < endOffset;
}
internal static void ThrowExceptionForHR(int hr)
{
// E_FAIL indicates "no info".
// E_NOTIMPL indicates a lack of ISymUnmanagedReader support (in a particular implementation).
if (hr < 0 && hr != E_FAIL && hr != E_NOTIMPL)
{
Marshal.ThrowExceptionForHR(hr, s_ignoreIErrorInfo);
}
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Roslyn.Test.Utilities
{
public static class HResult
{
public const int S_OK = 0x0;
public const int S_FALSE = 0x1;
public const int E_FAIL = unchecked((int)0x80004005);
public const int E_NOTIMPL = unchecked((int)0x80004001);
}
}
......@@ -138,7 +138,8 @@
<Compile Include="FX\EncodingUtilities.cs" />
<Compile Include="FX\EnsureEnglishUICulture.cs" />
<Compile Include="FX\EnsureInvariantCulture.cs" />
<Compile Include="FX\EventWaiter.cs" />
<Compile Include="FX\EventWaiter.cs" />
<Compile Include="FX\HResult.cs" />
<Compile Include="FX\ImmutableArrayTestExtensions.cs" />
<Compile Include="FX\MonoHelpers.cs" />
<Compile Include="FX\PinnedBlob.cs" />
......
......@@ -1205,7 +1205,13 @@ private static EditAndContinueMethodDebugInformation GetNativeEncDebugInfo(ISymU
byte[] debugInfo;
try
{
debugInfo = symReader.GetCustomDebugInfoBytes(methodToken, methodVersion: 1);
debugInfo = symReader.GetCustomDebugInfo(methodToken, methodVersion: 1);
}
catch (ArgumentOutOfRangeException)
{
// Sometimes the debugger returns the HRESULT for ArgumentOutOfRangeException, rather than E_FAIL,
// for methods without custom debug info (https://github.com/dotnet/roslyn/issues/4138).
debugInfo = null;
}
catch (Exception e) when (FatalError.ReportWithoutCrash(e)) // likely a bug in the compiler/debugger
{
......
......@@ -212,11 +212,6 @@
<DependentUpon>VSPackage.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup Label="Linked Files">
<Compile Include="..\..\..\Test\PdbUtilities\Shared\SymUnmanagedReaderExtensions.cs">
<Link>Shared\SymUnmanagedReaderExtensions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Compilers\Core\Portable\CodeAnalysis.csproj">
<Project>{1EE8CAD3-55F9-4D91-96B2-084641DA9A6C}</Project>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册