Improve target framework reporting #330
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reports wanting to output the target framework of the test assembly have historically accessed
TestEnvironment.TargetFramework
which has only approximated the value by looking up the insufficientTargetFrameworkAttribute
in the assembly's metadata. This results in strings such as ".NETCoreApp,Version=v8.0" where users would expect and prefer "net8.0" as appears literally in the csproj. This assembly metadata is also "lossy" with respect to less common target framework monikers like "net8.0-windows", where the OS suffix information would be lost.This PR improves the values of
TestEnvironment.TargetFramework
in two ways:dotnet fixie
has 100% accurate access to the values in the csproj, we use this value verbatim during console runs.dotnet fixie
(ie VS Test Explorer), we fall back to theTargetFrameworkAttribute
but are willing to simplify that string to "netX.Y" format when the more verbose string has an obvious transformation available. IfTargetFrameworkAttribute
has some other format, it is allowed to pass through unaltered. This can be "lossy" with respect to things like the optional OS suffix, but is the best available value. Note that the target framework name that appears in VS Test Explorer's own tree of tests is exactly as lossy independent of test framework, and likely for the same reason.