Skip to content

Conversation

@Arlodotexe
Copy link
Member

Summary

This PR contains all necessary changes to close #4, and some additional quality of life changes.

Refactored SampleGen source generator

  • Enables getting attributes attached to method symbols
  • Adds the ToolkitSampleButtonActionAttribute and all the necessary plumbing to use it (see below)

Refactored SampleGen test tooling

Until recently, tests only checked the diagnostic output of a source generator, not the actual generated code. This changed with CommunityToolkit/Labs-Windows#336 when we added the PaneOption_GeneratesTitleProperty test.

  • This test also needed to check the sample registry, which is generated in the app head instead of the sample project.
  • This resulted in a copy-pasted method that worked well for that test, but not for the new tests.
  • We needed to properly recreate the Head-Sample project reference setup we have in our solution. These changes now enable that.

WIP: Pending issues

This PR is still work in progress. There may still be some functional bugs and missing plumbing:

  • Source generator sometimes doesn't see the button attribute. Cause unknown, seems random.
  • When the button does generate:
    • Binding to the command in your own sample should work as expected
    • Clicking the button in the generated options pane will do nothing. This is because:
      • The sample registry is a single tree of objects created at the app head
      • The same sample data is provided to all controls
      • The data does not have access to the control consuming it, and thus has no way to call the instance method for our button.

@Arlodotexe Arlodotexe added enhancement New feature or request dev loop ➰ For issues that impact the core dev-loop of building experiments source generator ⚙️ labels Apr 11, 2023
@Arlodotexe
Copy link
Member Author

@michael-hawker Looks like C# 11 isn't supported by the .NET 6 SDK? We need this for string literals """.

@michael-hawker
Copy link
Member

@michael-hawker Looks like C# 11 isn't supported by the .NET 6 SDK? We need this for string literals """.

Yeah .NET 6 = C#10, .NET 7 = C#11, so we'd need to bump the version in the build.yml/global.config to be installed/used for build. Should be fine, we can still target .NET 6 so, none of the other stuff should have to change.

@Arlodotexe
Copy link
Member Author

This PR is experiencing a major blocker related to the source generator. The generated button option has been removed and the remaining changes and improvements have been moved to #69.

As a substitute, we'll use a custom options pane that can hold any sample options we need.

@Arlodotexe Arlodotexe closed this Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev loop ➰ For issues that impact the core dev-loop of building experiments enhancement New feature or request source generator ⚙️

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToolkitSampleButtonAction Attribute

2 participants