Skip to content
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

Provide information to users if a C# suggestion cannot be applied because of e.g. a lower language version used in project #13

Open
ironcev opened this issue Nov 20, 2017 · 3 comments

Comments

@ironcev
Copy link
Member

ironcev commented Nov 20, 2017

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.

@ironcev ironcev changed the title Provide suggestions only for the C# language version specified in the project settings (and lower versions) Provide information to users if a C# suggestion cannot be applied because of a lower language version used in project Mar 1, 2019
@ironcev ironcev changed the title Provide information to users if a C# suggestion cannot be applied because of a lower language version used in project Provide information to users if a C# suggestion cannot be applied because of e.g. a lower language version used in project May 21, 2019
@ironcev
Copy link
Member Author

ironcev commented May 21, 2019

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.

image

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.)

@shankyjain7243
Copy link
Contributor

Sample screenshot if a suggestion is not compatible with language version of the project.
Sharpen_Suggestion

@ironcev
Copy link
Member Author

ironcev commented Aug 3, 2019

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 via Microsoft.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:

  • We need a richer abstraction of a C# version then just an enum. See Create a proper abstraction for C# language version #12. (I will try to add more info to the Create a proper abstraction for C# language version #12 so that is clear why we need a richer abstraction and what it should contain.)
  • Even if a simple enum would be enough, we still cannot use the 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants