Skip to content

error CS8603: Possible null reference return in generated code using SourceGen #32478

@StepKie

Description

@StepKie

Description

cc @simonrozsival, c.f. discussion in MauiVerse Discord

Given the following xaml:

<Entry Text="{Binding SomeNullableObject.SomeStringProperty}"/>

using <MauiXamlInflator>SourceGen</MauiXamlInflator>
this will cause a

error CS8603: Possible null reference return.

in the generated delegate

return Create(
	getter: static source => source.SomeNullableObject?.SomeStringProperty,
	extension.Mode,
	extension.Converter,
	extension.ConverterParameter,
	extension.StringFormat,
	extension.Source,
	extension.FallbackValue,
	extension.TargetNullValue);

I guess this is related to #32402, where something was implemented for value types, not reference types.

I guess it should work for strings specifically, as we often want to bind nullable strings to Entry, Editor, or other wrapped custom controls.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

10.0.0-rc.2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

No response

Affected platforms

Android, Windows, iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

Labels

area-xamlXAML, CSS, Triggers, Behaviorsi/regressionThis issue described a confirmed regression on a currently supported versionplatform/androidplatform/iosplatform/windowsregressed-in-10-rc2s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingxsgXaml sourceGen

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions