zompinc / sync-method-generator

Generates a synchronized version of an async method
MIT License
48 stars 4 forks source link

Fix enum pattern matching #86

Closed GerardSmit closed 1 month ago

GerardSmit commented 1 month ago

When using is pattern matching with enums, the enum value is dropped. For example:

_ = System.Data.ConnectionState.Closed is System.Data.ConnectionState.Closed;

Gets converted to:

_ = System.Data.ConnectionState.Closed is global::System.Data.ConnectionState;

This PR checks if the type is an enum and doesn't match the base typeSyntax (because the right-side is missing) and then adds it back.

virzak commented 1 month ago

Thanks a lot for the PR.

I expanded your test case to cover using static class.

The change is in the latest nuget package.