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

Use CancellationToken in AvaloniaNameGenerator #12043

Merged
merged 4 commits into from
Jul 6, 2023

Conversation

jankrib
Copy link
Contributor

@jankrib jankrib commented Jul 5, 2023

What does the pull request do?

I was experiencing severe performance issues in visual studio with a larger project with many axaml files. The better solution here is probably to implement the newer IIncrementalGenerator interface, but I noticed that the generation was not using the CancellationToken. This made a huge difference for me.

What is the current behavior?

It keeps generating all the xaml files even if the operation is cancelled

What is the updated/expected behavior with this PR?

The generation is cancelled if the CancellationToken reports so.

How was the solution implemented (if it's not obvious)?

I tried to churn as little as possible, but had to change the return type from IReadOnlyList to IEnumerable to get the lazy behavior wanted by the foreach loop.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037391-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@timunie
Copy link
Contributor

timunie commented Jul 5, 2023

I think incremental generator was planned, but not available back then. Don't know how easy it would be to implement that interface at this stage though.

@jankrib
Copy link
Contributor Author

jankrib commented Jul 5, 2023

I looked into it. It is pretty trivial but requires refactoring. I gave it a quick go, but the way options are made from the old context made me try this simple fix instead. Using it now it doesn't feel slow and the project is quite large.

@maxkatz6 maxkatz6 enabled auto-merge July 5, 2023 19:41
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037432-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@jmacato jmacato disabled auto-merge July 6, 2023 10:51
@jmacato jmacato enabled auto-merge July 6, 2023 10:51
@jmacato jmacato disabled auto-merge July 6, 2023 12:27
@jmacato jmacato merged commit 9806f27 into AvaloniaUI:master Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants