Skip to content

Conversation

OsirisTerje
Copy link
Member

@OsirisTerje OsirisTerje commented Aug 23, 2024

Fixes #4798

I followed the idea from @stevenaw and made this into a test.
The test is in folder for SolutionTests, indicating that it doesn't test code, but tests the setup of the projects.

Writing code like this with XML parsing and so is not something I am very fond out, so I did take some "help" from the ChatGPT "friend". The parsing code it did pretty well, but the logic - that was more of a struggle. I believe I have managed to clean up most of that, after NNN iterations, but there certainly some more weirdoes around there. Appreciate some good comments!

The first commit shows the error, so the action should go red.
The next commit will fix that error, and should go green.

The code takes the csproj as the "truth" and checks that the nuspec have the same setup. Right now it says the System.Memory is missing in the .net6.0 dependency group in the nuspec, but we know that is should instead be placed under the .netframework condition in the csproj. Some thinking is still needed from the devs :-)

@OsirisTerje
Copy link
Member Author

Ok... stylecop.. love you....
That's for tomorrow.....

Make the reader classes nested inside the fixture.
@manfred-brands
Copy link
Member

Ok... stylecop.. love you.... That's for tomorrow.....

I have fixed this. StyleCop is your friend and for my work we have rules set to error so they will be fixed before CI kicks in. Initially it is a hassle for developers new to the code, but in the end they all love it as they don't have to do rework.
Anyhow, I accepted that people here wanted these as warnings as to not slow initial development.

I added a few more changes to my commit:

  1. Ensure all paths use a forward / as separator so it works for both Windows and Unix like OS.
  2. Ensure casing of file names is correct so it works on Case Sensitive file systems.
  3. Moved your classes as nested inside the unit test. If reviewing my changes use the ignore whitespace option.
  4. Small optimization for the double dictionary lookup.

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 Code looks good. I asked a few questions to see if we need more checks.

@OsirisTerje
Copy link
Member Author

OsirisTerje commented Aug 24, 2024

Ok... stylecop.. love you.... That's for tomorrow.....

I have fixed this. StyleCop is your friend

Yes, I know, but you're far better @manfred-brands ! Thanks !

PS: Wish that StyleCop was a Roslyn analyzer with the possibility to auto fix all these things.

@manfred-brands
Copy link
Member

PS: Wish that StyleCop was a Roslyn analyzer with the possibility to auto fix all these things.

It is and has many CodeFixes

@OsirisTerje
Copy link
Member Author

OsirisTerje commented Aug 24, 2024

But is that a separate analyzer to be installed, or do we have it already?

UPDATE

Found it! Thanks @manfred-brands

@manfred-brands
Copy link
Member

@OsirisTerje Thanks for the excellent start, I added more functionality:

  1. Parameterized the test so it now also checks nunitlite.nuspec
  2. Augmented the test to also check the version number of the packages so that if we update in source the nuspec also gets updated.

I think we are done, but as I should not approve things I worked on @stevenaw can you do the final review please?

Copy link
Member

@stevenaw stevenaw left a comment

Choose a reason for hiding this comment

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

Thanks @OsirisTerje @manfred-brands
LGTM. Seems robust and no real concerns of any note on my end. Passes locally for me. One nitpick suggestion about test naming consistency and clarity

Co-authored-by: Steven Weerdenburg <stevenaw@users.noreply.github.com>
@stevenaw
Copy link
Member

Thanks for accepting the suggestion @OsirisTerje
This looks good to me if it looks good to @manfred-brands

@OsirisTerje OsirisTerje merged commit 5c0ae90 into main Aug 25, 2024
5 checks passed
@OsirisTerje OsirisTerje deleted the CSprojNuspecTest branch August 25, 2024 19:26
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.

Add a test to ensure direct framework dependencies in csproj are reflected in nuspec
3 participants