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

[XC] fix compiled bindings containing arrays #25949

Merged
merged 1 commit into from
Nov 20, 2024
Merged

[XC] fix compiled bindings containing arrays #25949

merged 1 commit into from
Nov 20, 2024

Conversation

StephaneDelcroix
Copy link
Contributor

Description of Change

don't get the property on the array type but on the element type

Issues Fixed

don't get the property on the array type but on the element type

- fixes #25819
@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner November 19, 2024 15:52
@StephaneDelcroix StephaneDelcroix added this to the .NET 9 SR2 milestone Nov 19, 2024
@@ -1005,12 +1010,12 @@ static IEnumerable<Instruction> CompiledBindingGetHandlers(TypeReference tSource
il.Emit(Ldarga_S, (byte)0);
else
il.Emit(Ldarg_0);
var lastGetterTypeRef = properties[i - 1].property.PropertyType;
var lastGetterTypeRef = properties[i - 1].property?.PropertyType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this and the next change are preventing the NRE reported as the issue

@@ -666,7 +666,12 @@ static bool TryParsePath(ILContext context, string path, TypeReference tSourceRe
previousPartTypeRef = indexer.PropertyType.ResolveGenericParameters(indexerDeclTypeRef);
}
else
{
if (previousPartTypeRef.IsArray)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this makes it produce valid, executable, and correct code

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

LGTM

With regards to the fix, is the first one fixing the issue, but the second chunk just stopping the crash even if we didn't fix it so we would rather have code that does nothing/something instead of crashing?

@StephaneDelcroix
Copy link
Contributor Author

With regards to the fix, is the first one fixing the issue, but the second chunk just stopping the crash even if we didn't fix it so we would rather have code that does nothing/something instead of crashing?

both are needed. the reported exception was a NRE, and the code should go through that null ref to end up on the actual fix. This is all strange, as this used to work, but the capability was somehow broken at some point, and we didn't had test for that part

@rmarinho rmarinho merged commit 82bf412 into main Nov 20, 2024
110 checks passed
@rmarinho rmarinho deleted the fix_25819 branch November 20, 2024 11:34
@samhouts samhouts added fixed-in-9.0.21 fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed-in-9.0.21 fixed-in-net8.0-nightly This may be available in a nightly release!
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

XAML Data Binding Error - Object reference not set to an instance of an object.
5 participants