-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix: Xaml Compiler error when code-behind class contains a DllImport
method
#12882
Conversation
@@ -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()) |
There was a problem hiding this comment.
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.
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`
…class contains a DllImport method
Head branch was pushed to by a user without write access
f645a6d
to
2637a9c
Compare
@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 test this PR using the following package version. |
…` 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
What does the pull request do?
Avoid Avalonia error
AVLN0004
when xaml code-behind class contains aDllImport
methodWhat 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 whereIsPInvokeImpl
istrue
.Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes #10046
Depended from #12881