-
Notifications
You must be signed in to change notification settings - Fork 509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SA1119
false positives on System.Range
syntax
#3370
Comments
I ran into a similar issue, but in this case it is the
from x in (12..)
from y in 1..3
select x + y; |
@FreeApophis could you provide more context for your code snippet? using System;
using System.Collections.Generic;
public class C {
public void M() {
var z = from x in (12..)
from y in 1..3
select x + y;
}
}
public static class RangeExtensions
{
public static IEnumerable<int> SelectMany(this Range range, Func<Range, IEnumerable<int>> func)
{
return new int[] {0};
}
} |
Yes, the typesystem needs a bit more than just that to make it work. Here is the changeset which makes it possible to use ranges in foreach and from clauses: The Funcky version is not yet released with this feature in it, but this pre-release should have the feature: |
SA1119
is giving false positives forSystem.Range
syntax. If you make an extension method onSystem.Range
(perhaps something likeToArray()
), you must wrap the range syntax in parentheses because method calls are higher priority than range syntax. Example:The parentheses are required in the above example, but
SA1119
thinks they are not necessary, and when you perform the auto-correct feature ofSA1119
it removes the parentheses breaking your code with a compiler error.The text was updated successfully, but these errors were encountered: