Created
January 18, 2012 15:58
-
-
Save jmaxxz/1633719 to your computer and use it in GitHub Desktop.
This rule set detects calls that are likely to cause runtime exceptions on IQueryable types. To add this rule set do: Resharper->Options->Custom Patterns ->Import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<CustomPatterns> | |
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP"> | |
<Comment>FirstOrDefault not supported by all Queryable Types</Comment> | |
<ReplaceComment>Convert to supported version</ReplaceComment> | |
<ReplacePattern>$q$.Where($x$).FirstOrDefault()</ReplacePattern> | |
<SearchPattern>$q$.FirstOrDefault($x$)</SearchPattern> | |
<Params /> | |
<Placeholders> | |
<ExpressionPlaceholder Name="q" ExpressionType="System.Linq.IQueryable" ExactType="False" /> | |
<ArgumentPlaceholder Name="x" Minimal="1" Maximal="-1" /> | |
</Placeholders> | |
</Pattern> | |
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP"> | |
<Comment>First not supported by all Queryable Types</Comment> | |
<ReplaceComment>Convert to supported version</ReplaceComment> | |
<ReplacePattern>$q$.Where($x$).First()</ReplacePattern> | |
<SearchPattern>$q$.First($x$)</SearchPattern> | |
<Params /> | |
<Placeholders> | |
<ExpressionPlaceholder Name="q" ExpressionType="System.Linq.IQueryable" ExactType="False" /> | |
<ArgumentPlaceholder Name="x" Minimal="1" Maximal="-1" /> | |
</Placeholders> | |
</Pattern> | |
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP"> | |
<Comment>Single not supported by all Queryable Types</Comment> | |
<ReplaceComment>Convert to supported version</ReplaceComment> | |
<ReplacePattern>$q$.Where($x$).Single()</ReplacePattern> | |
<SearchPattern>$q$.Single($x$)</SearchPattern> | |
<Params /> | |
<Placeholders> | |
<ExpressionPlaceholder Name="q" ExpressionType="System.Linq.IQueryable" ExactType="False" /> | |
<ArgumentPlaceholder Name="x" Minimal="1" Maximal="-1" /> | |
</Placeholders> | |
</Pattern> | |
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP"> | |
<Comment>SingleOrDefault not supported by all Queryable Types</Comment> | |
<ReplaceComment>Convert to supported version</ReplaceComment> | |
<ReplacePattern>$q$.Where($x$).SingleOrDefault()</ReplacePattern> | |
<SearchPattern>$q$.SingleOrDefault($x$)</SearchPattern> | |
<Params /> | |
<Placeholders> | |
<ExpressionPlaceholder Name="q" ExpressionType="System.Linq.IQueryable" ExactType="False" /> | |
<ArgumentPlaceholder Name="x" Minimal="1" Maximal="-1" /> | |
</Placeholders> | |
</Pattern> | |
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP"> | |
<Comment>Any not supported by all Queryable Types</Comment> | |
<ReplaceComment>Convert to supported version</ReplaceComment> | |
<ReplacePattern>$q$.Where($x$).Any()</ReplacePattern> | |
<SearchPattern>$q$.Any($x$)</SearchPattern> | |
<Params /> | |
<Placeholders> | |
<ExpressionPlaceholder Name="q" ExpressionType="System.Linq.IQueryable" ExactType="False" /> | |
<ArgumentPlaceholder Name="x" Minimal="1" Maximal="-1" /> | |
</Placeholders> | |
</Pattern> | |
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP"> | |
<Comment>All not supported by all Queryable Types</Comment> | |
<ReplaceComment>Convert to supported version</ReplaceComment> | |
<ReplacePattern>$q$.Where($x$).All()</ReplacePattern> | |
<SearchPattern>$q$.All($x$)</SearchPattern> | |
<Params /> | |
<Placeholders> | |
<ExpressionPlaceholder Name="q" ExpressionType="System.Linq.IQueryable" ExactType="False" /> | |
<ArgumentPlaceholder Name="x" Minimal="1" Maximal="-1" /> | |
</Placeholders> | |
</Pattern> | |
</CustomPatterns> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment