Open ironcev opened 6 years ago
A lower language version used in the project is just one of the possible reasons why a suggestion cannot be applied. Type availability in the framework is another one. E.g. only some of the features of C# 8.0 are directly supported in .NET 4.8.
We could even have a situation that the framework version does not support a certain type like e.g. Range
but the project uses NuGet packages that provide the type.
On the other hand, for e.g. Default interface implementation there are no special framework types needed, but the feature will work only on the Core runtime (at the moment).
Long story short: it's complex 😄 So in general, think well about what it really means that a particular suggestion can be applied in a particular piece of code.
(The table with language feature and framework support is taken from @miroslavpopovic's presentation that can be found in his what-is-new-in-dotnet-core-3 repository.)
Sample screenshot if a suggestion is not compatible with language version of the project.
Thanks for digging deeper into the issue @shankyjain7243.
I'll answer the question from your PR #26 here so that we have all the things in one place and document at the same time some additional difficulties we have in this issue.
We are using
CSharpLanguageVersions
class to identify language versions, which can also be done viaMicrosoft.CodeAnalysis.CSharp.LanguageVersion
enum, do I replace the class with the enum around the source code ?
No, this replacement wouldn't work. Why? Because of these two major reasons:
Microsoft.CodeAnalysis.CSharp.LanguageVersion
enum. The reason lies in the problem described in the Roslyn Dependencies at Build and Runtime lab experiment. Basically, we develop Sharpen with an older Roslyn version so that it can run in VS2017. In that version the Microsoft.CodeAnalysis.CSharp.LanguageVersion
enum does not contain all the language version for which we have suggestions, e.g. the version 8.0.In the meanwhile, two more difficulties popped up. The first one is explained in this TODO. Basically, we can have analyzers that analyze files from a certain project and report findings in different projects. The solution provided in the PR does not support that, same as the existing implementation of the analyzers.
The second one is the larger-scale refactoring which we want to do, basically fixing all the points mentioned in the above TODO.
The PR #26 is a WIP as the title suggests but I wouldn't integrate it before we solve the other issues which are pretty heavy:
So I will close the PR and I suggest that we postpone the work on this issue until all the points above are closed. Thanks once again for providing more info!
E.g. if the project sets the C# language version to 5.0 in its settings, the suggestions for e.g. version 7.0 will also be provided in the Sharpen Results window. We need a mechanism to provide visual information to users that the particular suggestion cannot be applied because the project settings use a lower version of the compiler.
We need a more detailed UX/UI concept how to do this.