dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.07k stars 4.04k forks source link

Add support to get target framework version from Project #4464

Closed hvanbakel closed 9 years ago

hvanbakel commented 9 years ago

See also: https://social.msdn.microsoft.com/Forums/vstudio/en-US/58bb72c4-ed10-4965-81a4-a4950d6ccbdc/targeted-net-framework-version?forum=roslyn

It would be useful to be able to determine the framework version that is targeted. An example of a use case, some analyzers might apply (or not) to a specific framework version.

tmeschter commented 9 years ago

@srivatsn @mavasani This is where analyzer options would come in handy.

@hvanbakel One option is to create an MSBuild task that writes the framework version to a file, and then include that as an additional file. The analyzer could then read the value from the file. Admittedly not very straightforward (my MSBuild skills are not good enough to explain in detail how to do it) but it is possible.

srivatsn commented 9 years ago

This would a part of #3798. We'll just use that issue to track the larger problem.