|
|
@ -248,12 +248,15 @@ namespace ICSharpCode.Decompiler |
|
|
|
/// Gets the source code and type name from metadata token and offset.
|
|
|
|
/// Gets the source code and type name from metadata token and offset.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="codeMappings">Code mappings storage.</param>
|
|
|
|
/// <param name="codeMappings">Code mappings storage.</param>
|
|
|
|
|
|
|
|
/// <param name="currentTypeFullName">Current type name.</param>
|
|
|
|
/// <param name="token">Metadata token.</param>
|
|
|
|
/// <param name="token">Metadata token.</param>
|
|
|
|
/// <param name="ilOffset">IL offset.</param>
|
|
|
|
/// <param name="ilOffset">IL offset.</param>
|
|
|
|
/// <param name="typeName">Type definition.</param>
|
|
|
|
/// <param name="typeName">Type definition.</param>
|
|
|
|
/// <param name="line">Line number.</param>
|
|
|
|
/// <param name="line">Line number.</param>
|
|
|
|
|
|
|
|
/// <remarks>It is possible to exist to different types from different assemblies with the same metadata token.</remarks>
|
|
|
|
public static bool GetSourceCodeFromMetadataTokenAndOffset( |
|
|
|
public static bool GetSourceCodeFromMetadataTokenAndOffset( |
|
|
|
this ConcurrentDictionary<string, List<MemberMapping>> codeMappings, |
|
|
|
this ConcurrentDictionary<string, List<MemberMapping>> codeMappings, |
|
|
|
|
|
|
|
string currentTypeFullName, |
|
|
|
uint token, |
|
|
|
uint token, |
|
|
|
int ilOffset, |
|
|
|
int ilOffset, |
|
|
|
out TypeDefinition type, |
|
|
|
out TypeDefinition type, |
|
|
@ -262,18 +265,19 @@ namespace ICSharpCode.Decompiler |
|
|
|
type = null; |
|
|
|
type = null; |
|
|
|
line = 0; |
|
|
|
line = 0; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var typename in codeMappings.Keys) { |
|
|
|
if (!codeMappings.ContainsKey(currentTypeFullName)) |
|
|
|
var mapping = codeMappings[typename].Find(m => m.MetadataToken == token); |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mapping = codeMappings[currentTypeFullName].Find(m => m.MetadataToken == token); |
|
|
|
if (mapping == null) |
|
|
|
if (mapping == null) |
|
|
|
continue; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
var codeMapping = mapping.MemberCodeMappings.Find( |
|
|
|
var codeMapping = mapping.MemberCodeMappings.Find( |
|
|
|
cm => cm.ILInstructionOffset.From <= ilOffset && ilOffset <= cm.ILInstructionOffset.To - 1); |
|
|
|
cm => cm.ILInstructionOffset.From <= ilOffset && ilOffset <= cm.ILInstructionOffset.To - 1); |
|
|
|
if (codeMapping == null) { |
|
|
|
if (codeMapping == null) { |
|
|
|
codeMapping = mapping.MemberCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset)); |
|
|
|
codeMapping = mapping.MemberCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset)); |
|
|
|
if (codeMapping == null) { |
|
|
|
if (codeMapping == null) { |
|
|
|
codeMapping = mapping.MemberCodeMappings.LastOrDefault(); |
|
|
|
codeMapping = mapping.MemberCodeMappings.LastOrDefault(); |
|
|
|
if (codeMapping == null) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -281,8 +285,5 @@ namespace ICSharpCode.Decompiler |
|
|
|
line = codeMapping.SourceCodeLine; |
|
|
|
line = codeMapping.SourceCodeLine; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|