diff --git a/Src/Test/PdbUtilities/Shared/ISymUnmanagedVariable.cs b/Src/Test/PdbUtilities/Shared/ISymUnmanagedVariable.cs index 4ce19d586b132d97a32a4cf64f0d42a47eacfba8..39b109f4262ce27b57b4d4c531e8f026dab8b5b4 100644 --- a/Src/Test/PdbUtilities/Shared/ISymUnmanagedVariable.cs +++ b/Src/Test/PdbUtilities/Shared/ISymUnmanagedVariable.cs @@ -12,7 +12,7 @@ namespace Roslyn.Utilities.Pdb internal interface ISymUnmanagedVariable { void GetName(int cchName, out int pcchName, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] char[] name); - void GetAttributes(out int pRetVal); + void GetAttributes(out uint pRetVal); void GetSignature(int cSig, out int pcSig, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] byte[] sig); // the following methods are useless (not implemented, or returning a constant): diff --git a/Src/Test/PdbUtilities/Shared/SymUnmanagedReaderExtensions.cs b/Src/Test/PdbUtilities/Shared/SymUnmanagedReaderExtensions.cs index 68b94eb5fbacba7493ef4b9784ea70f27e0b4c38..929abb6e9f3fd8c9adbe1e0464303547c88e4732 100644 --- a/Src/Test/PdbUtilities/Shared/SymUnmanagedReaderExtensions.cs +++ b/Src/Test/PdbUtilities/Shared/SymUnmanagedReaderExtensions.cs @@ -31,7 +31,7 @@ internal static ISymUnmanagedMethod GetBaselineMethod(this ISymUnmanagedReader r /// /// Returns local names indexed by slot. /// - internal static ImmutableArray GetLocalNames(this ISymUnmanagedReader symReader, int methodToken, int ilOffset, bool isScopeEndInclusive) + internal static ImmutableArray GetLocalNames(this ISymUnmanagedReader symReader, int methodToken, int ilOffset, bool isScopeEndInclusive, uint? attributesToIgnore) { if (symReader == null) { @@ -39,15 +39,15 @@ internal static ImmutableArray GetLocalNames(this ISymUnmanagedReader sy } var symMethod = symReader.GetBaselineMethod(methodToken); - return symMethod.GetLocalVariableSlots(ilOffset, isScopeEndInclusive); + return symMethod.GetLocalVariableSlots(ilOffset, isScopeEndInclusive, attributesToIgnore); } internal static ImmutableArray GetLocalVariableSlots(this ISymUnmanagedMethod method) { - return GetLocalVariableSlots(method, offset: -1, isScopeEndInclusive: false); + return GetLocalVariableSlots(method, offset: -1, isScopeEndInclusive: false, attributesToIgnoreOpt: null); } - internal static ImmutableArray GetLocalVariableSlots(this ISymUnmanagedMethod method, int offset, bool isScopeEndInclusive) + internal static ImmutableArray GetLocalVariableSlots(this ISymUnmanagedMethod method, int offset, bool isScopeEndInclusive, uint? attributesToIgnoreOpt) { char[] nameBuffer = null; string[] result = null; @@ -57,8 +57,21 @@ internal static ImmutableArray GetLocalVariableSlots(this ISymUnmanagedM ISymUnmanagedVariable[] localsBuffer = null; + bool haveAttributesToIgnore = attributesToIgnoreOpt.HasValue; + uint attributesToIgnore = attributesToIgnoreOpt.GetValueOrDefault(); + ForEachLocalVariableRecursive(rootScope, offset, isScopeEndInclusive, ref localsBuffer, local => { + if (haveAttributesToIgnore) + { + uint attributes; + local.GetAttributes(out attributes); + if (attributes == attributesToIgnore) + { + return; + } + } + int nameLength; local.GetName(0, out nameLength, null); @@ -77,7 +90,7 @@ internal static ImmutableArray GetLocalVariableSlots(this ISymUnmanagedM EnsureBufferSize(ref result, slot + 1); - // nameLength is NUL-terminated + // nameBuffer is NUL-terminated Debug.Assert(nameBuffer[nameLength - 1] == '\0'); result[slot] = new string(nameBuffer, 0, nameLength - 1); }