Skip to content

Commit

Permalink
Catch when it's a different type or the method is missing due to vers…
Browse files Browse the repository at this point in the history
…ion issues
  • Loading branch information
GrahamTheCoder committed Feb 13, 2024
1 parent c0745d8 commit 18e8526
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CodeConverter/CSharp/CachedReflectedDelegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ public static SyntaxTree GetEmbeddedSyntaxTree(this Location loc) =>
GetCachedReflectedPropertyDelegate(loc, "PossiblyEmbeddedOrMySourceTree", ref _possiblyEmbeddedOrMySourceTree);
private static Func<Location, SyntaxTree> _possiblyEmbeddedOrMySourceTree;

public static bool GetIsUsing(this ILocalSymbol l) =>
GetCachedReflectedPropertyDelegate(l, "IsUsing", ref _isUsing);
public static bool GetIsUsing(this ILocalSymbol l)
{
try {
return GetCachedReflectedPropertyDelegate(l, "IsUsing", ref _isUsing);
} catch (Exception) {
return false;
}
}

private static Func<ILocalSymbol, bool> _isUsing;


Expand Down

0 comments on commit 18e8526

Please sign in to comment.