-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
RCS1047 "Remove Async suffix" is incorrectly reported for IAsyncEnumerable #1084
Comments
The bug seems to also affect a lot more cases (e.g. everything except a direct I made a try at it, and it ends up really complex (even ignoring the fact that the enumerator might not implement Examples of also failing cases of valid IAsyncEnumerables: public static class Test
{
public static T EnumerateGenericAsync<T>() where T : IAsyncEnumerable<T>
{
return default!;
}
public static Base EnumerateBaseAsync()
{
return default!;
}
public static Inherited EnumerateInheritedAsync()
{
return default!;
}
public static T EnumerateBaseOfTAsync<T>() where T : Base
{
return default!;
}
public static T EnumerateInheritedOfTAsync<T>() where T : IAsyncEnumerable<T>
{
return default!;
}
}
public class Inherited : Base
{
}
public class Base : IAsyncEnumerable<string>
{
public IAsyncEnumerator<string> GetAsyncEnumerator(CancellationToken cancellationToken = default) => default!;
} |
Hi, Do you want to do a PR? If yes, then following methods might help you:
|
Sure thing. I think I'll probably just do a fix for types implementing |
Original title: RCS1047 "Remove Async suffix" is incorrectly reported for IAsyncEnumerables
Product and Version Used:
Roslynator 4.3.0 on Visual Studio 2022 17.5.5 64bit
Steps to Reproduce:
Actual Behavior:
The
EnumerateAsync
-method'sAsync
-suffix is faded, and roslynator suggests to remove the suffix. If the returned type implementsIAsyncEnumerable<>
, the analyzer isn't triggered. This might be intended or an oversight, and luckily it's not a big deal if it won't be fixed.Expected Behavior:
The analyzer could check if the type implements
GetAsyncEnumerator
directly. This is another can of worms too, though, since the enumerator isn't required to implement the interface either, as long as it hasCurrent
andMoveNextAsync()
.My reasoning for foregoing the interface is to avoid the enumerable/enumerator accidentally being used with
LINQ or boxed to be used anywhere except the callsite. As for the suffix, there are synchronous overloads in the same class, and I wanted to separate the ones returning an async enumerable.
The text was updated successfully, but these errors were encountered: