Permalink
Browse files

Fix TypeLoad exception

Don't use unversioned types in iterators
  • Loading branch information...
SLaks committed Feb 17, 2014
1 parent ea2abfb commit 2c52df7be397c052980bf91d2bcc6a90eae9c926
Showing with 9 additions and 2 deletions.
  1. +9 −2 Ref12/Services/LanguageUtilities.cs
@@ -18,15 +18,22 @@ static class LanguageUtilities {
int charIndex = Math.Max(snapshotPoint.Position - containingLine.Start.Position, 0);
return new Position(containingLine.LineNumber, charIndex);
}
private static Tuple<int, int> ToCSharpTuple(SnapshotPoint corePoint, ITextSnapshot snapshot = null) {
var p = ToCSharpPosition(corePoint, snapshot);
return Tuple.Create(p.Line, p.Character);
}
public static IEnumerable<GoToDefLocation> GetGoToDefLocations(SnapshotPoint triggerPoint, string sourceFileName) {
Position position = ToCSharpPosition(triggerPoint, null);
// I cannot use Position, because it will be compiled into a
// a field in the iterator type, which will throw a TypeLoad
// exception before I add my AssemblyResolve handler.
var position = ToCSharpTuple(triggerPoint, null);
string[] fileNames, rqNames, assemblyBinaryNames;
int[] lines, columns;
bool[] isMetaDataFlags;
try {
NativeMethods.GoToDefinition_GetLocations(position.Line, position.Character, sourceFileName, out fileNames, out lines, out columns, out rqNames, out assemblyBinaryNames, out isMetaDataFlags);
NativeMethods.GoToDefinition_GetLocations(position.Item1, position.Item2, sourceFileName, out fileNames, out lines, out columns, out rqNames, out assemblyBinaryNames, out isMetaDataFlags);
} catch (InvalidOperationException) {
yield break;
}

0 comments on commit 2c52df7

Please sign in to comment.