Skip to content

Commit

Permalink
Warn when dot missing from target framework strings (#3692)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat authored Oct 13, 2020
1 parent b828348 commit 35126a1
Show file tree
Hide file tree
Showing 14 changed files with 556 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -857,5 +857,10 @@ public enum NuGetLogCode
/// Undefined package warning
/// </summary>
NU5500 = 5500,

/// <summary>
/// InvalidUndottedFrameworkWarning
/// </summary>
NU5501 = 5501,
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
NuGet.Common.NuGetLogCode.NU1010 = 1010 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU1011 = 1011 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5501 = 5501 -> NuGet.Common.NuGetLogCode
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NuGet.Common.NuGetLogCode.NU1010 = 1010 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU1011 = 1011 -> NuGet.Common.NuGetLogCode

NuGet.Common.NuGetLogCode.NU5501 = 5501 -> NuGet.Common.NuGetLogCode
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NuGet.Common.NuGetLogCode.NU1010 = 1010 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU1011 = 1011 -> NuGet.Common.NuGetLogCode

NuGet.Common.NuGetLogCode.NU5501 = 5501 -> NuGet.Common.NuGetLogCode
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ public int GetHashCode(ContentItem obj)
var hashCode = 0;
foreach (var property in obj.Properties)
{
if (property.Key.EndsWith("_raw", StringComparison.OrdinalIgnoreCase))
{
continue;
}
hashCode ^= property.Key.GetHashCode();
hashCode ^= property.Value.GetHashCode();
}
Expand All @@ -264,6 +268,12 @@ public bool Equals(ContentItem x, ContentItem y)

foreach (var xProperty in x.Properties)
{
if (xProperty.Key.EndsWith("_raw", StringComparison.OrdinalIgnoreCase))
{
// We've started storing raw versions of each key, but
// we don't want that to affect results.
continue;
}
object yValue;
if (!y.Properties.TryGetValue(xProperty.Key, out yValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ internal override bool TryMatch(
Path = path
};
}

item.Properties.Add(_token + "_raw", substring);
item.Properties.Add(_token, value);
}
endIndex = delimiterIndex;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInDependencyGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInFilesWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInFrameworkAssemblyGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInReferenceGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkWarning.get -> string
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInDependencyGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInFilesWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInFrameworkAssemblyGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInReferenceGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkWarning.get -> string
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInDependencyGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInFilesWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInFrameworkAssemblyGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkInReferenceGroupsWarning.get -> string
static NuGet.Packaging.Rules.AnalysisResources.InvalidUndottedFrameworkWarning.get -> string
45 changes: 45 additions & 0 deletions src/NuGet.Core/NuGet.Packaging/Rules/AnalysisResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/NuGet.Core/NuGet.Packaging/Rules/AnalysisResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@
<data name="InvalidPrereleaseDependencyWarning" xml:space="preserve">
<value>A stable release of a package should not have a prerelease dependency. Either modify the version spec of dependency "{0}" or update the version field in the nuspec.</value>
</data>
<data name="InvalidUndottedFrameworkInDependencyGroupsWarning" xml:space="preserve">
<value>The following dependency group(s) require(s) dots in the framework version: {0}</value>
<comment>0 - comma-separated list of target frameworks</comment>
</data>
<data name="InvalidUndottedFrameworkInFilesWarning" xml:space="preserve">
<value>The following packaged file folder(s) require(s) dots in the framework version: {0}</value>
<comment>0 - comma-separated list of paths</comment>
</data>
<data name="InvalidUndottedFrameworkInFrameworkAssemblyGroupsWarning" xml:space="preserve">
<value>The following framework assembly group(s) require(s) dots in the framework version: {0}</value>
<comment>0 - comma-separated list of target frameworks</comment>
</data>
<data name="InvalidUndottedFrameworkInReferenceGroupsWarning" xml:space="preserve">
<value>The following reference group(s) require(s) dots in the framework version: {0}</value>
<comment>0 - comma-separated list of target frameworks</comment>
</data>
<data name="InvalidUndottedFrameworkWarning" xml:space="preserve">
<value>One or more target framework specifiers in your package are missing required dots in their framework version numbers. This is required as of .NET5.0. Please rename them to include dots as needed (e.g. 'net50' to 'net5.0').</value>
</data>
<data name="LegacyVersionWarning" xml:space="preserve">
<value>The package version '{0}' uses SemVer 2.0.0 or components of SemVer 1.0.0 that are not supported on legacy clients. Change the package version to a SemVer 1.0.0 string. If the version contains a release label it must start with a letter. This message can be ignored if the package is not intended for older clients.</value>
</data>
Expand Down
Loading

0 comments on commit 35126a1

Please sign in to comment.