ServiceBusExplorer icon indicating copy to clipboard operation
ServiceBusExplorer copied to clipboard

Replace Nunit with xUnit

Open asos-gurpreetsingh opened this issue 1 year ago • 29 comments

asos-gurpreetsingh avatar Aug 08 '24 14:08 asos-gurpreetsingh

Thanks @SeanFeldman , are we saying that if we update the Nunit package then we want to use fluent assertions otherwise we will never update Nunit package ? I am happy to use fluent assertions, I only took the path of least change in order to update nunit

asos-gurpreetsingh avatar Aug 08 '24 14:08 asos-gurpreetsingh

Is the new API mandatory for the latest version of NUnit?

SeanFeldman avatar Aug 08 '24 14:08 SeanFeldman

The old methods were not available when I updated. Anyway I will refactor to use fluent assertions, I would prefer that too

asos-gurpreetsingh avatar Aug 08 '24 14:08 asos-gurpreetsingh

Thanks, @asos-gurpreetsingh. If you're already at it, we might as well swap NUnit with XUnit. It's a more commonly used library this days, including MSFT projects.

SeanFeldman avatar Aug 08 '24 15:08 SeanFeldman

Sure @SeanFeldman I will get the sorted.

asos-gurpreetsingh avatar Aug 09 '24 08:08 asos-gurpreetsingh

@SeanFeldman I have migrated this to XUnit. Could you please also have a look at the workflow (not my strong suite)

asos-gurpreetsingh avatar Aug 09 '24 13:08 asos-gurpreetsingh

I don't recall wherever PR build should have a version or not. @ErikMogensen do you remember?

Screenshot_2024-08-12-07-29-57-87_40deb401b9ffe8e1df2f1cc5ba480b12

SeanFeldman avatar Aug 12 '24 13:08 SeanFeldman

I don't recall wherever PR build should have a version or not. @ErikMogensen do you remember?

Screenshot_2024-08-12-07-29-57-87_40deb401b9ffe8e1df2f1cc5ba480b12

I added default input for workflow manual build that is what shows version number here, without this i cannot test build in feature branch, it could not find version release-version which is set as env variable.

asos-gurpreetsingh avatar Aug 12 '24 14:08 asos-gurpreetsingh

I don't recall wherever PR build should have a version or not. @ErikMogensen do you remember?

They do not have a version number so this is correct.

ErikMogensen avatar Aug 12 '24 17:08 ErikMogensen

So what is next ? who will complete the PR ?

asos-gurpreetsingh avatar Aug 14 '24 09:08 asos-gurpreetsingh

So what is next ? who will complete the PR ?

Patience. This is not paid work, and people have their own priorities :)

SeanFeldman avatar Aug 14 '24 16:08 SeanFeldman

@asos-gurpreetsingh, approved with a few suggestions. We usually try to have two reviewers on something that's a minor change. With the build version change on top of xUnit, I'll let @ErikMogensen get another pass. The good news is that this is looking good and close to completion. Thank you.

SeanFeldman avatar Aug 14 '24 16:08 SeanFeldman

So what is next ? who will complete the PR ?

Patience. This is not paid work, and people have their own priorities :)

Apologies, I did not mean to pressure, I just wanted to know what's next.

asos-gurpreetsingh avatar Aug 15 '24 10:08 asos-gurpreetsingh

I tested to build this branch using dotnet build -c RELEASE -p:GenerateAssemblyInfo=true,AssemblyVersion=0.1.2.3,InformationalVersion=0.0.1.1. It sets File version to the same value as the Assembly version, which we don't want. Assembly version should be set per assembly. File version should be the same on all assemblies created by the build.

ErikMogensen avatar Aug 17 '24 09:08 ErikMogensen

@asos-gurpreetsingh, do you plan to complete this one? Erik pointed out one last thing that needs attention.

SeanFeldman avatar Sep 13 '24 13:09 SeanFeldman

@asos-gurpreetsingh, do you plan to complete this one? Erik pointed out one last thing that needs attention.

Hi Yes I will pick this weekend, i was out on holiday

asos-gurpreetsingh avatar Sep 18 '24 15:09 asos-gurpreetsingh

I tested to build this branch using dotnet build -c RELEASE -p:GenerateAssemblyInfo=true,AssemblyVersion=0.1.2.3,InformationalVersion=0.0.1.1. It sets File version to the same value as the Assembly version, which we don't want. Assembly version should be set per assembly. File version should be the same on all assemblies created by the build.

In your test you have used very different version numbers, if our objective is to use something like 1.2.3.0 as assembly version and 1.2.3.566 as file version then this command would do that. But if we really want to set different versions like in you example then we can use another Property "FileVersion" for that

asos-gurpreetsingh avatar Sep 20 '24 09:09 asos-gurpreetsingh

Yes, we want to be able to set different versions. Thinking of this, I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline.

ErikMogensen avatar Sep 21 '24 08:09 ErikMogensen

There is also an issue with the build.

ErikMogensen avatar Sep 21 '24 08:09 ErikMogensen

Yes, we want to be able to set different versions. Thinking of this, I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline.

Can I ask why ? We could use git-version to drive version numbers.

asos-gurpreetsingh avatar Sep 21 '24 21:09 asos-gurpreetsingh

There is also an issue with the build.

build is fixed.

asos-gurpreetsingh avatar Sep 25 '24 09:09 asos-gurpreetsingh

Yes, we want to be able to set different versions. Thinking of this, I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline.

Can I ask why ? We could use git-version to drive version numbers.

Of course. Assembly version is used by the .NET runtime to determine and verify it is loading the intended assembly. The assembly number of a dependent assembly is stored in the manifest of the calling assembly. By default it will only load that assembly.

File version may be used for installers to determine which version an assembly has so the numbers have different purposes.

By setting all the assemblies built in a build to have the same file version it is easy to tell for an installer and a human which build a certain assembly belongs to. Typically you do not want to change the assembly version in every build since that would make assemblies between two different builds incompatible. The exception to this if you have made changes in the assembly that lost its backward combability, then it should increase its assembly number.

Does this PR still set the assembly version to the same value on all assemblies?

ErikMogensen avatar Sep 30 '24 20:09 ErikMogensen

Yes, we want to be able to set different versions. Thinking of this, I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline.

Can I ask why ? We could use git-version to drive version numbers.

Of course. Assembly version is used by the .NET runtime to determine and verify it is loading the intended assembly. The assembly number of a dependent assembly is stored in the manifest of the calling assembly. By default it will only load that assembly.

File version may be used for installers to determine which version an assembly has so the numbers have different purposes.

By setting all the assemblies built in a build to have the same file version it is easy to tell for an installer and a human which build a certain assembly belongs to. Typically you do not want to change the assembly version in every build since that would make assemblies between two different builds incompatible. The exception to this if you have made changes in the assembly that lost its backward combability, then it should increase its assembly number.

Does this PR still set the assembly version to the same value on all assemblies?

Thanks, @ErikMogensen . I understand now why one could want different versions but I am not sure we SBE uses it with that intent. But with current state of build task "dotnet build ....." allows us to use different versions for file and assembly but that will be applied to all assemblies. I don't think this we ever set up to use different file versions for each project. That can be done by setting those in the project files. Secondly if that is what we want then we can pick this up in another change and not this one.

asos-gurpreetsingh avatar Oct 02 '24 09:10 asos-gurpreetsingh

Thanks, @ErikMogensen . I understand now why one could want different versions but I am not sure we SBE uses it with that intent.

We should probably have updated the assembly numbers in some PRs.

But with current state of build task "dotnet build ....." allows us to use different versions for file and assembly but that will be applied to all assemblies. I don't think this we ever set up to use different file versions for each project. That can be done by setting those in the project files.

We don't want to have different file versions for assemblies in the same build so that's fine.

Secondly if that is what we want then we can pick this up in another change and not this one.

All work on this tool is voluntarily so there is quite a big risk that such a change will never be created.

What is the problem with using msbuild for building?

ErikMogensen avatar Oct 04 '24 16:10 ErikMogensen

Thanks, @ErikMogensen . I understand now why one could want different versions but I am not sure we SBE uses it with that intent.

We should probably have updated the assembly numbers in some PRs.

But with current state of build task "dotnet build ....." allows us to use different versions for file and assembly but that will be applied to all assemblies. I don't think this we ever set up to use different file versions for each project. That can be done by setting those in the project files.

We don't want to have different file versions for assemblies in the same build so that's fine.

Secondly if that is what we want then we can pick this up in another change and not this one.

All work on this tool is voluntarily so there is quite a big risk that such a change will never be created.

What is the problem with using msbuild for building?

Apologies @ErikMogensen if I am missing something. when you say "I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline. " what is that to do with MSBuild or dotnet build ? and secondly "using a file belonging to the project of the affected assembly" sounds contradicting to "We don't want to have different file versions for assemblies". Could you please elaborate. Thanks

asos-gurpreetsingh avatar Oct 07 '24 13:10 asos-gurpreetsingh

Apologies @ErikMogensen if I am missing something. when you say "I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline. " what is that to do with MSBuild or dotnet build ?

I assumed dotnet build cannot handle assembly version set in a project since you changed the way assembly versions were set. But if it is possible to set assembly versions using files belonging to each project and still use dotnet build, it would be great.

secondly "using a file belonging to the project of the affected assembly" sounds contradicting to "We don't want to have different file versions for assemblies". Could you please elaborate. Thanks

It is about File version vs Assembly version. We want to have the same File version on all assemblies created by the build. We want Assembly version set separately for each assembly.

Just ask again if it is unclear.

ErikMogensen avatar Oct 11 '24 04:10 ErikMogensen

Apologies @ErikMogensen if I am missing something. when you say "I want the assembly version to be set using a file belonging to the project of the affected assembly instead of being set in the pipeline. " what is that to do with MSBuild or dotnet build ?

I assumed dotnet build cannot handle assembly version set in a project since you changed the way assembly versions were set. But if it is possible to set assembly versions using files belonging to each project and still use dotnet build, it would be great.

secondly "using a file belonging to the project of the affected assembly" sounds contradicting to "We don't want to have different file versions for assemblies". Could you please elaborate. Thanks

It is about File version vs Assembly version. We want to have the same File version on all assemblies created by the build. We want Assembly version set separately for each assembly.

Just ask again if it is unclear.

Thanks @ErikMogensen . In that case file version can be set by dotnet build, but setting different assembly versions for each assembly would mean updating project files manually when needed. What assembly version should we set to start with ? when would it be changed (on what basis)

asos-gurpreetsingh avatar Oct 11 '24 09:10 asos-gurpreetsingh

Thanks @ErikMogensen . In that case file version can be set by dotnet build, but setting different assembly versions for each assembly would mean updating project files manually when needed.

Great!

What assembly version should we set to start with ?

Look with the ones that are in the main branch. (I believe all are 1.0.0,0 which is most likely not right.) Since this PR changed the .NET version, increment the major version digit (the first one).

when would it be changed (on what basis)

They should be increased when there is new release of the assembly with an interface that is not backwards compatible. By interface I mean, public methods, properties, interfaces, events and delegates. (I may have forgotten one or two.) Also, if the runtime requirements change I consider that a change that should increase the version number.

ErikMogensen avatar Oct 12 '24 13:10 ErikMogensen

@ErikMogensen I have set set the assembly versions to 1.0.0.1 in all projects and build script will provide the file version. We should be able to change the assembly versions from projects now. I have updated the tests to reflect that too. Please check if this works as you expected. Could you also confirm that the publish process is not affected by this. (i have checked and it does not look like it should be affected, but please check).

asos-gurpreetsingh avatar Oct 20 '24 21:10 asos-gurpreetsingh

Well done @asos-gurpreetsingh !

ErikMogensen avatar Oct 27 '24 12:10 ErikMogensen