-
Notifications
You must be signed in to change notification settings - Fork 29
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
Async breaks MustNotResolveCurrentTimeViaDateTimeConventionSpecification #62
Comments
Hrmm good catch @gkinsman - I can only assume that this would apply for any property accessors within async methods? We can get the async state machine's type - check out https://github.com/andrewabest/Conventional/blob/master/Conventional/Conventions/Cecil/LibraryCodeShouldCallConfigureAwaitWhenAwaitingTasksConventionSpecification.cs#L82 Let me have a play with this today - hopefully it is easy enough to retrieve the state machine type for any state machines in our parent type and browse their code for offending useages. |
That was fairly straight forward :) can you have a gander at the PR? If you think it has solved the problem too, I'll merge it in once you've given it the thumbs up and the build is green. |
Looks great! Have added some comments and a PR to your PR for some additional edge cases and a minor refactoring, let me know what you think! |
Sorry about the break in comms George, will take a peek at this today! |
Team work makes the dream work! Thanks for your help with this one @gkinsman. |
Hi there!
Given a type:
the following IL is generated:
which is easily detected by the
MustNotResolveCurrentTimeViaDateTimeConventionSpecification
which searches for anyget_Now
calls onDateTime
.What happens if this method is made async though (ignoring the void return type)?
Foo.Bar
now looks like:with the call to
DateTime.Now
pushed to the state machine, here it's the first step:This makes the convention pass when it shouldn't, as the call to the prohibited method is now in a separate type to that that the search is being performed on.
Is there some way to follow the generated state machine's type and search within the generated code? Maybe this is a convention better suited to roslyn, as it has the raw syntax tree?
The text was updated successfully, but these errors were encountered: