Skip to content

Xunitcodegen#4020

Closed
tznind wants to merge 25 commits intogui-cs:v2_developfrom
tznind:xunitcodegen
Closed

Xunitcodegen#4020
tznind wants to merge 25 commits intogui-cs:v2_developfrom
tznind:xunitcodegen

Conversation

@tznind
Copy link
Copy Markdown
Collaborator

@tznind tznind commented Apr 5, 2025

Fixes

This is a super set of #4015 which is when I started working on this

Noteworthy

I had to change the package version from 4.13,5 to 4.12.0 on the CSharp and Analyzers code gen dependencies - otherwise I got warnings. I don't see any issues doing this but am happy to discuss if others have any build issues.

UPDATE: CI wanted a different version so I set it in the props to use either which seems to work with locally and in CI now.

I created this repo to help understand how codegen works: https://github.com/tznind/CodeGenerationExample

Proposed Changes/Todos

Adds all xunit methods (e.g. Assert.False to the fluent API as concatenated name e.g. AssertFalse)

image

How does it work?

We create an xunit project that is empty

  • TerminalGuiFluentTestingXunit

We create a code generator project that creates code in the empty project

  • TerminalGuiFluentTestingXunit.Generator

Result is that when compiled the empty project contains generated static extension methods to the fluent context that perform the asserts and shutdown safely:

image

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@tznind tznind requested a review from tig as a code owner April 5, 2025 12:26
@tznind
Copy link
Copy Markdown
Collaborator Author

tznind commented Apr 6, 2025

@tig this should make your asserts much easier in menu branch. No more passing lamdas and works for all assert methods (true, starts with, IsType etc).

I think for Application members we can just manually add the methods for now. SendKeys and Focus are the only new ones added recently, and I don't imagine there will be all that many more

Only issue I've had is sometimes having to close and re open visual studio before autocomplete works following changes to code gen (i.e. to see the new members)

I did look to see if it was possible yo bring in the xmldoc too but looks impossible/complicated because code gen builds from the symbol source not original source

@tznind tznind changed the title #Fixes Xunitcodegen Xunitcodegen Apr 7, 2025
@tznind
Copy link
Copy Markdown
Collaborator Author

tznind commented Apr 12, 2025

@tig I'm going to close this as #4024 is just this + more bugfixes and features

@tznind tznind closed this Apr 12, 2025
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.

Assert and Application fluent testing support

1 participant