Skip to content

Commit

Permalink
Trim leading v from TargetFrameworkVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Jan 23, 2025
1 parent 5c3c07b commit 9b3ef43
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ private static bool PlatformAnalysisAllowed(AnalyzerOptions options, Compilation
string tfmVersion = options.GetMSBuildPropertyValue(MSBuildPropertyOptionNames.TargetFrameworkVersion, compilation) ?? "";

if (tfmIdentifier.Equals(NetCoreAppIdentifier, StringComparison.OrdinalIgnoreCase) &&
tfmVersion.StartsWith("v", StringComparison.OrdinalIgnoreCase) &&
Version.TryParse(tfmVersion[1..], out var version) &&
Version.TryParse(tfmVersion.TrimStart(['v', 'V']), out var version) &&
version.Major >= 5)
{
// We want to only support cases we know are well-formed by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public static IEnumerable<object[]> Create_DifferentTfms()

// Custom TFMs with valid user specified Identifier/Version
yield return new object[] { "build_property.TargetFramework = nonesense\nbuild_property.TargetFrameworkIdentifier=.NETCoreApp\nbuild_property.TargetFrameworkVersion=v11.0", true };
yield return new object[] { "build_property.TargetFramework = nonesense\nbuild_property.TargetFrameworkIdentifier=.NETCoreApp\nbuild_property.TargetFrameworkVersion=V11.0", true };
yield return new object[] { "build_property.TargetFramework = nonesense\nbuild_property.TargetFrameworkIdentifier=.NETCoreApp\nbuild_property.TargetFrameworkVersion=11.0", true };

// Custom TFMs with invalid user specified Identifier/Version
yield return new object[] { "build_property.TargetFramework = nonesense\nbuild_property.TargetFrameworkIdentifier=.NETCoreApp\nbuild_property.TargetFrameworkVersion=v5", false };
Expand Down

0 comments on commit 9b3ef43

Please sign in to comment.