Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
version: '5.0.{build}'
image: Visual Studio 2022

assembly_info:
patch: true
file: AssemblyInfo.*
assembly_version: "{version}"
assembly_file_version: "{version}"
assembly_informational_version: "{version}"

dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'
# No assembly_info / dotnet_csproj patching: every version derives from the <Version> in
# src/Directory.Build.props, and the version above only labels the AppVeyor build.

build:
project: src/
Expand Down
1 change: 0 additions & 1 deletion src/ConsoleApplication/ConsoleApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<ImplicitUsings>disable</ImplicitUsings>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\System.Net.IPNetwork.snk</AssemblyOriginatorKeyFile>
<Version>5.0.1</Version>
<RootNamespace>System.Net</RootNamespace>
<LangVersion>latestmajor</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<Project>
<PropertyGroup>
<!-- The one version of the whole solution. Package, assembly and file versions all derive from it,
a release overrides it with /p:Version=<tag>, and versionize bumps it here. -->
<Version>5.0.1</Version>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<!-- Some SDK distributions (Homebrew among them) ship ILCompiler and ILLink.Tasks in a local
library-packs feed whose packages hash differently from nuget.org. Restoring from it writes
Expand Down
14 changes: 2 additions & 12 deletions src/System.Net.IPNetwork/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2e650d19-7041-43bd-acab-48a0b2ff2524")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.1.0")]
// AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion are generated from the
// <Version> in src/Directory.Build.props, see System.Net.IPNetwork.csproj.
[assembly: InternalsVisibleTo("TestProject, PublicKey=00240000048000009400000006020000002400005253413100040000010001004d29ae79cfcf603de0200afc96f4d8304aa857341b78e706fedb3f0ac9c9d613443cea78a1ee687def573ad45b5cdc0abeeb1db304eec7c07331015d8aeeb3fd5e092273a2347e6cb54803a00484807c64bc3092f17619abfc5290133efad358a27747bfe71d1dc23b461d7cf91272844fc7a8390dc63b16236729dadb2c21bc")]
13 changes: 11 additions & 2 deletions src/System.Net.IPNetwork/System.Net.IPNetwork.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@
<TargetFrameworks>net10.0;net9.0;net8.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>IPNetwork2</PackageId>
<PackageVersion>5.0.1</PackageVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!-- The version attributes are generated from $(Version); the descriptive ones stay in Properties/AssemblyInfo.cs. -->
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<!-- The assembly is strong-named: AssemblyVersion only follows the major version, so that minor and
patch releases do not force consumers to recompile. FileVersion carries the full version. -->
<AssemblyVersion>$([System.Text.RegularExpressions.Regex]::Match($(Version), '^\d+').Value).0.0.0</AssemblyVersion>
<FileVersion>$([System.Text.RegularExpressions.Regex]::Match($(Version), '^\d+\.\d+\.\d+').Value).0</FileVersion>
<PackageProjectUrl>https://github.com/lduchosal/ipnetwork</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>https://github.com/lduchosal/ipnetwork/pulls?q=is%3Apr</PackageReleaseNotes>
Expand Down
5 changes: 4 additions & 1 deletion src/TestProject/TestProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<SignAssembly Condition="'$(OS)' != 'Windows_NT'">true</SignAssembly>
<AssemblyOriginatorKeyFile>..\System.Net.IPNetwork.snk</AssemblyOriginatorKeyFile>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Version>5.0.1</Version>
<LangVersion>latestmajor</LangVersion>
<NoWarn>SA1010</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -53,6 +52,10 @@
<ProjectReference Include="..\ConsoleApplication\ConsoleApplication.csproj" Condition="'$(TargetFramework)' == 'net10.0'" />
<ProjectReference Include="..\System.Net.IPNetwork\System.Net.IPNetwork.csproj" />
</ItemGroup>
<ItemGroup>
<!-- Read by VersionConsistencyUnitTest to check every assembly carries the solution version. -->
<AssemblyMetadata Include="ExpectedVersion" Value="$(Version)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net10.0'">
<Compile Remove="ArchitectureTest.cs" />
<Compile Remove="ConsoleUnitTest.cs" />
Expand Down
64 changes: 64 additions & 0 deletions src/TestProject/VersionConsistencyUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// <copyright file="VersionConsistencyUnitTest.cs" company="IPNetwork">
// Copyright (c) IPNetwork. All rights reserved.
// </copyright>

namespace TestProject;

using System.Reflection;
using System.Text.RegularExpressions;

/// <summary>
/// Guards the single source of the version: every assembly must carry the <c>Version</c> of
/// src/Directory.Build.props, or the one a release passes with /p:Version. The test project records
/// that version at build time as the <c>ExpectedVersion</c> assembly metadata.
/// </summary>
[TestClass]
public class VersionConsistencyUnitTest
{
/// <summary>
/// The strong-named library pins AssemblyVersion to the major version and carries the full
/// version in its file and informational versions.
/// </summary>
[TestMethod]
public void TestLibraryVersionsFollowTheSolutionVersion()
{
string expected = ExpectedVersion();
string numeric = Regex.Match(expected, @"^\d+\.\d+\.\d+").Value;

Check warning on line 26 in src/TestProject/VersionConsistencyUnitTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.

See more on https://sonarcloud.io/project/issues?id=lduchosal_ipnetwork&issues=AaFuoYK_N1YzpLYIRGV1&open=AaFuoYK_N1YzpLYIRGV1&pullRequest=461
string major = Regex.Match(expected, @"^\d+").Value;

Check warning on line 27 in src/TestProject/VersionConsistencyUnitTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.

See more on https://sonarcloud.io/project/issues?id=lduchosal_ipnetwork&issues=AaFuoYK_N1YzpLYIRGV2&open=AaFuoYK_N1YzpLYIRGV2&pullRequest=461
Assembly library = typeof(IPNetwork2).Assembly;

Assert.AreEqual(new Version($"{major}.0.0.0"), library.GetName().Version, "AssemblyVersion");
Assert.AreEqual(
$"{numeric}.0",
library.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version,
"AssemblyFileVersion");
StringAssert.StartsWith(
library.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion,
expected,
"AssemblyInformationalVersion");

Check warning on line 38 in src/TestProject/VersionConsistencyUnitTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use 'Assert.StartsWith' instead of 'StringAssert.StartsWith'

See more on https://sonarcloud.io/project/issues?id=lduchosal_ipnetwork&issues=AaFuoYK_N1YzpLYIRGVz&open=AaFuoYK_N1YzpLYIRGVz&pullRequest=461
}

#if NET5_0_OR_GREATER
/// <summary>
/// The console application reports its AssemblyVersion with --version, so it carries the full version.
/// </summary>
[TestMethod]
public void TestConsoleVersionFollowsTheSolutionVersion()
{
string numeric = Regex.Match(ExpectedVersion(), @"^\d+\.\d+\.\d+").Value;

Check warning on line 48 in src/TestProject/VersionConsistencyUnitTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.

See more on https://sonarcloud.io/project/issues?id=lduchosal_ipnetwork&issues=AaFuoYK_N1YzpLYIRGV0&open=AaFuoYK_N1YzpLYIRGV0&pullRequest=461

Assert.AreEqual(new Version($"{numeric}.0"), typeof(Program).Assembly.GetName().Version, "AssemblyVersion");
}
#endif

private static string ExpectedVersion()
{
string? expected = typeof(VersionConsistencyUnitTest).Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(attribute => attribute.Key == "ExpectedVersion")
?.Value;

Assert.IsFalse(string.IsNullOrEmpty(expected), "The test project does not record ExpectedVersion.");
return expected!;
}
}
Loading