Skip to content

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

Closed

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

Activity

  1. added
    t/bug
    on Nov 10, 2025
  2. simonrozsival commented on Nov 10, 2025

    @simonrozsival
    Member

    I believe this is similar to #32402 - just for reference types. Let's see if Copilot can fix it, otherwise I'll try to look into it later this week.

  3. added this to the .NET 10.0 SR2 milestone on Nov 10, 2025
  4. added
    xsg
    area-xaml
    on Nov 11, 2025
  5. TamilarasanSF4853 commented on Nov 11, 2025

    @TamilarasanSF4853
    Contributor

    This issue has been validated in Visual Studio Code 1.105.1 and Visual Studio Insiders 11123.170 with MAUI versions 10.0.0-rc.1 and 10.0.0-rc.2. It can be reproduced on MAUI version 10.0.0-rc.2 on Android, iOS, Windows platforms.

    NullValueIssue.zip

  6. added
    s/verified
    s/triaged
    i/regression
    on Nov 11, 2025
  7. locked and limited conversation to collaborators on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-xamli/regressionplatform/androidplatform/iosplatform/windowsregressed-in-10-rc2s/triageds/verifiedt/bugxsg

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions