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

Enable AllowUnsafeBlocks for Gallery and Test heads under Windows App SDK #223

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

Arlodotexe
Copy link
Member

@Arlodotexe Arlodotexe commented Oct 28, 2024

This PR fixes the error annotations in the Gallery head when running the latest WindowsAppSDK and CsWinRT:

build (3, wasdk): tooling/ProjectHeads/AllComponents/Wasdk/obj/x64/Release/net8.0-windows10.0.19041.0/win-x64/Styles/ItemTemplates.g.i.cs#L13
Type 'ItemTemplates' implements generic WinRT interfaces which requires generated code using unsafe for trimming and AOT compatibility if passed across the WinRT ABI.
Project needs to be updated with '<AllowUnsafeBlocks>true</AllowUnsafeBlocks>'. 

See https://github.com/CommunityToolkit/Labs-Windows/actions/runs/11560414170

@michael-hawker
Copy link
Member

I'm still confused on what WinRT is trying to do here that requires unsafe codeblocks for ItemTemplates and how that's going to cascade through all our other projects... that seems bad/undesired?

@Sergio0694 do you know what this is about?

@Sergio0694
Copy link
Member

@michael-hawker it's just the way CsWinRT works. It's a known concern, but ultimately it just needs unsafe code. It's only impacting a specific subset of projects (it only triggers when you need to marshal some type of generic types), and we added an analyzer in CsWinRT to at least emit a useful and clear message if you don't have it enabled already. Note that it's common practice to enforce this, eg. the COM interop generator also requires you to allow unsafe blocks 🙂

@michael-hawker
Copy link
Member

@Sergio0694 thanks Sergio, good to know. Just wanted to call it out, as it'd be a concern if it causes problems later where we see apps which have to take this on now run into problems with accidentally running unsafe code unintentionally (or for those that want to explicitly restrict it).

@Arlodotexe Arlodotexe merged commit d61602f into main Oct 28, 2024
8 checks passed
@Arlodotexe Arlodotexe deleted the gallery/heads/wasdk/allowunsafeblocks branch October 28, 2024 23:00
Arlodotexe added a commit to CommunityToolkit/Labs-Windows that referenced this pull request Oct 28, 2024
Arlodotexe added a commit to CommunityToolkit/Windows that referenced this pull request Oct 28, 2024
Arlodotexe added a commit to CommunityToolkit/Windows that referenced this pull request Oct 29, 2024
@Arlodotexe Arlodotexe self-assigned this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants