Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #4705 - Wrong version numbers in dlls #4706

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

OsirisTerje
Copy link
Member

Fixes #4705

src/AssemblyInfo.g.cs Outdated Show resolved Hide resolved
Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OsirisTerje Sorry for the delay, I was off sick and couldn't concentrate enough to do reviews.
I also like code generation, but I do think your second option is nicer.
I think we can remove a lot of conditionals in the other projects by utilizing the AssemblyConfiguration set in the Directroy.Build.props

build.cake Show resolved Hide resolved
src/NUnitFramework/Directory.Build.props Outdated Show resolved Hide resolved
src/NUnitFramework/Directory.Build.props Outdated Show resolved Hide resolved
src/NUnitFramework/Directory.Build.props Outdated Show resolved Hide resolved
src/NUnitFramework/framework/nunit.framework.csproj Outdated Show resolved Hide resolved
src/NUnitFramework/nunitlite/nunitlite.csproj Outdated Show resolved Hide resolved
@OsirisTerje OsirisTerje changed the title Fixes Issue #4705 Fixes Issue #4705 - Wrong version numbers in dlls May 13, 2024
Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added various unnecessary null suppression operators (!).
All of them are unnecessary as NUnit.Analyzer does the suppressing for us as it knows those cannot be null.

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still some issues.

CakeScripts.Tests/Usings.cs Show resolved Hide resolved
src/NUnitFramework/tests/CakeTests.cs Outdated Show resolved Hide resolved
src/NUnitFramework/tests/WorkItemTests.cs Outdated Show resolved Hide resolved
src/NUnitFramework/TestBuilder.cs Outdated Show resolved Hide resolved
Comment on lines 7 to 22
[TestCase("1.2.3-beta.1", "1.2.3.1")]
[TestCase("1.2.3", "1.2.3.0")]
public void ThatWeCanParseFileVersionStrings(string versionString, string expected)
{

var parsedVersion = VersionParsers.ParseFileVersion(versionString);
Assert.That(parsedVersion, Is.EqualTo(expected));
}

[TestCase("1.2.3-beta.1", "1.2.3.0")]
[TestCase("1.2.3", "1.2.3.0")]
public void ThatWeCanParseAssemblyVersionStrings(string versionString, string expected)
{
var parsedVersion = VersionParsers.ParseAssemblyVersion(versionString);
Assert.That(parsedVersion, Is.EqualTo(expected));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you have Assembly and File version the wrong way around.
As per documentation the AssemblyVersion must be unique

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manfred-brands The AssemblyVersion should indicate the Major.Minor version (above also patch in included, but we're not quite semver yet), and not change for each build or revision. The FileVersion (aka AssemblyFileVersion) should change for all patches and revisons.
To me it looks like that is what the code above do.
Or do you see something I don't (not surprised though).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code does what you say it does. But my interpretation of the linked documentation is that the AssembyVersion should be unique so the .NET Resolver find the correct instance.
If one builds against 1.2.3-beta.1 then later against 1.2.3-beta.2 which has a bugfix, how would the compiler (and developer) know that we have the correct version if both are versioned as 1.2.3.0.
Maybe one of our native English (@stevenaw ?) speakers can read the linked documentation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! (I am not at all certain about how this should be) Perhaps also @CharliePoole who raised the issue can chime in here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key idea in the documentation seems to be expressed here:

"Suppose you're building a framework assembly for your project that is used by lot of developers while building the application assemblies. If you release new version of assembly frequently, say once every day, and if assemblies are strong named, Developers will have to change the reference every time you release new assembly. It can be cumbersome and may lead to wrong references also. A better option in such closed group and volatile scenarios would be to fix [i.e. keep the same] the AssemblyVersion and change only the AssemblyFileVersion. Use the assembly file version number to communicate the latest release of assembly. In this case, developers won't have to change the references and they can overwrite the assembly in reference path. In central or final release builds it makes more sense to change the AssemblyVersion and most keep the AssemblyFileVersion same as assembly version."

So Microsoft is suggesting to do one thing for internal development changes and the opposite for releases. In fact, that makes perfect sense to me. Normally, it should be easy for those inside the project to keep using a reference but outside users should have to make a decision to move ahead.

However, I don't think any of this addresses the issue I raised by email with @OsirisTerje. I was concerned that the three component Package Version did not match the either the AssemblyVersion or the AssemblyFileVersion of the primary assembly included in the package. While NuGet allows package versions to be completely independent from the versions of included assemblies, maintaining consistency between the two is helpful to users and I think it would be a good practice for NUnit to ensure that all three use the same major, minor and build components.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In central or final release builds it makes more sense to change the AssemblyVersion and most keep the AssemblyFileVersion same as assembly version.

Thanks @CharliePoole ! I then think this is the appropriate solution for us.

And Charlie - this does fix the issue. The issue arised because we had to manually set these numbers, and that was forgotten. Now they are automatically set together with the package version, and will follow the package version, given we now have a resolution for how these numbers should be :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not that easy. We want the AssemblyVersion to be (equal to or) higher than the beta releases. If we add the beta number as the 4th digit, that will be 0 for release, which means lower than the beta ones.
Earlier when we just did this manually, we kept the File and Assembly version numbers equal and fixed through the beta period.
image
and
image

So if we continue to follow this practice we would not create anything more than we potentially have had for years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The dll's in the release 4.1 has version 4.0.1
4 participants