andrewabest / Conventional

A suite of convention specifications for enforcing type and style conventions in your codebase
Microsoft Public License
97 stars 29 forks source link

TryGetSemanticModel doesn't seem to resolve the semantic model correctly #94

Closed paulegradie closed 4 months ago

paulegradie commented 5 months ago

Description

I've found (unfortunately) that the TryGetSemanticModel approach to resolving semantic models from a given document does not actually work 😓. I attempted to find workarounds, however nothing appears to solve the problem.

I've implemented a reproduction of the problem for you to review - but the short of it is: The tests that I've written in the repo suggest that we can swap the TryGetSemanticModel out with GetSemanticModelAsync().Result.

Testing:

Either way - this update can't make any thing worse. :D

Reproduction:

https://github.com/paulegradie/Conventional.Repros/blob/main/SemanticModelNotFound/SemanticModelNotFound.Tests/SemanticModelNotFoundTest.cs