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: Xaml Compiler error when code-behind class contains a DllImport method #12882

Merged
merged 5 commits into from
Sep 18, 2023

Conversation

workgroupengineering
Copy link
Contributor

What does the pull request do?

Avoid Avalonia error AVLN0004 when xaml code-behind class contains a DllImport method

What is the current behavior?

Throw error AVLN0004

What is the updated/expected behavior with this PR?

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

In XamlCompilerTaskExecutor, skip method body analysis where IsPInvokeImpl is true.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #10046
Depended from #12881

@@ -484,7 +484,7 @@ MethodDefinition CreateTrampolineMethod(bool hasSystemProviderArg)

var foundXamlLoader = false;
// Find AvaloniaXamlLoader.Load(this) or AvaloniaXamlLoader.Load(sp, this) and replace it with !XamlIlPopulateTrampoline(this)
foreach (var method in classTypeDefinition.Methods.ToArray())
foreach (var method in classTypeDefinition.Methods.Where(m=>!m.IsPInvokeImpl).ToArray())
Copy link
Member

Choose a reason for hiding this comment

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

We should just check if method.Body == null. There are other similar cases like abstract methods.

@workgroupengineering workgroupengineering marked this pull request as ready for review September 14, 2023 17:05
@grokys grokys enabled auto-merge September 14, 2023 22:26
if you put SourceGenerators.props in a project with path are like this:"C:\GitHub\Avalonia\sample\mobile\android\ANoteSample\ANoteSample.csproj", the Compiler is not able to found `Avalonia.Generators`
auto-merge was automatically disabled September 15, 2023 07:18

Head branch was pushed to by a user without write access

@maxkatz6
Copy link
Member

@workgroupengineering looking from CI logs, it seems like new project is packaged into a nuget file. Can you make sure it doesn't have IsPackable set (probably with some props file by accident)?
You can try to build nuke project locally to see what nuget packages are created.

@avaloniaui-team
Copy link
Contributor

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

@maxkatz6 maxkatz6 added this pull request to the merge queue Sep 18, 2023
Merged via the queue into AvaloniaUI:master with commit 1cb271f Sep 18, 2023
5 checks passed
@workgroupengineering workgroupengineering deleted the fixes/DllImport branch September 18, 2023 05:55
@maxkatz6 maxkatz6 added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Dec 7, 2023
@maxkatz6 maxkatz6 added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Jan 17, 2024
maxkatz6 pushed a commit that referenced this pull request Jan 17, 2024
…` method (#12882)

* fix: Avalonia.Generators not found

if you put SourceGenerators.props in a project with path are like this:"C:\GitHub\Avalonia\sample\mobile\android\ANoteSample\ANoteSample.csproj", the Compiler is not able to found `Avalonia.Generators`

* test: Add test #10046 Xaml Compiler error when code-behind class contains a DllImport method

* fix: Xaml Compiler error when code-behind class contains a DllImport method

* fix: Address Review

* fix: ValidateApiDiff has thrown an exception
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.

Xaml Compiler error when code-behind class contains a DllImport method
4 participants