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

Fix issue with template processing #26196

Merged
merged 6 commits into from
Jan 14, 2025
Merged

Fix issue with template processing #26196

merged 6 commits into from
Jan 14, 2025

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Nov 28, 2024

Description of Change

The template is processing the actual code

Fixes #27055

@mattleibow mattleibow requested a review from a team as a code owner November 28, 2024 11:12
Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

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

Is it possible to add a test? also can you create a issue associated with this?

@rmarinho rmarinho added this to the .NET 9 SR2 milestone Nov 28, 2024
@rmarinho rmarinho added the area-templates Project templates, Item Templates for Blazor and MAUI label Nov 28, 2024
@Eilon
Copy link
Member

Eilon commented Nov 30, 2024

Is it possible to add a test? also can you create a issue associated with this?

Unfortunately the template tests only create, build, and maybe publish the templates. None of the tests run the apps built by the template. It's certainly possible (somehow), but we don't do it at this time. I think you'd need to do that in order to test this?

@mattleibow
Copy link
Member Author

We could check the new template for the line

@Eilon
Copy link
Member

Eilon commented Dec 2, 2024

We could check the new template for the line

We could... but that's pretty random. Why check this one thing but not anything else?

@mattleibow
Copy link
Member Author

What else can we check? We would have to set up a template and then run it and then somehow communicate with the running ap to determine which handler is in use.

@Eilon
Copy link
Member

Eilon commented Dec 4, 2024

What else can we check? We would have to set up a template and then run it and then somehow communicate with the running ap to determine which handler is in use.

Yeah I think that's the only meaningful way to test it. I'm not at all saying it's easy: it's probably not.

A pattern I've seen before is to:

  1. Instantiate the template (dotnet new <stuff>)
  2. Add a little bit of instrumentation to it to make the app more 'inspectable', so like add TestInspector.cs to it that has magic code to 'test' things in the app (say, a check to make sure the right handler is actually registered, or that a font is installed, or that all controls have accessible descriptions, etc.)
  3. Run the app
  4. Have the test call into the TestInspector.cs functions to verify stuff

But if the test is just to check that the template output contains a string, I wouldn't even bother. It's not verifying the code is correct or even executed at all, let alone if it has the desired effect in the running app. And on top of that it's a very fragile test because a lot of changes that could be good changes could cause this test to fail (say we change MAUI to have this be built-in and not needed in the template, this test could start failing, even though there's nothing wrong).

@PureWeen PureWeen modified the milestones: .NET 9 SR2, .NET 9 SR3 Dec 4, 2024
@PureWeen PureWeen modified the milestones: .NET 9 SR3, .NET 9 SR4 Jan 5, 2025
@mattleibow
Copy link
Member Author

/rebase

@mattleibow
Copy link
Member Author

The handler registration is temporary and will be the default at some point soon. Also, I am testing the template result, not whether it is used. I can make a more complex test, but I don't think it is worth it because it is all going away soon.

@mattleibow mattleibow requested a review from rmarinho January 10, 2025 10:12
@mattleibow mattleibow modified the milestones: .NET 9 SR4, .NET 9 SR3 Jan 10, 2025
jsuarezruiz
jsuarezruiz previously approved these changes Jan 10, 2025
@mattleibow
Copy link
Member Author

/rebase

@mattleibow mattleibow self-assigned this Jan 13, 2025
@PureWeen PureWeen modified the milestones: .NET 9 SR3, .NET 9 SR4 Jan 14, 2025
@PureWeen PureWeen merged commit cffbb96 into main Jan 14, 2025
104 checks passed
@PureWeen PureWeen deleted the dev/fix-template branch January 14, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-templates Project templates, Item Templates for Blazor and MAUI
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Maui template with sample content is missing the handler registrations
5 participants