Skip to content

[BUG] Warning when including a ValueConverter starting in .NET MAUI 9 #2205

@hansmbakker

Description

@hansmbakker

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

Including a Converter from the MAUI Community Toolkit in a .NET MAUI 9 app triggers a warning

When referencing a converter (e.g. from the MAUI Community Toolkit) in XAML, xamlc generates a warning with code XC0103 in .NET 9 RC1. On .NET 8 this warning was not there.

This is especially annoying in projects where TreatWarningsAsErrors is enabled.

⚠️ The warning log below is a sample. However, this is an issue for all converters, not only for this specific IsNullConverter.

XamlC warning XC0103: Consider attributing the markup extension "CommunityToolkit.Maui.Converters.IsNullConverter" with [RequireService] or [AcceptEmptyServiceProvider] if it doesn't require any.

Expected Behavior

ValueConverters from the MAUI Community Toolkit can be included without triggering errors

Steps To Reproduce

  1. Create new MAUI project on .NET 9 RC1
  2. Add a converter to the main page's resources from the MAUI Community Toolkit
  3. Run dotnet build
  4. See the warning

Link to public reproduction project repository

https://github.com/hansmbakker/bugrepro-converter-issue

Environment

- .NET MAUI CommunityToolkit: 9.0.3
- OS:
- .NET MAUI: 9.0 RC1

Anything else?

This is caused by dotnet/maui#19650 / dotnet/maui#19945.

ValueConverters are expected to be attributed by RequireService or AcceptEmptyServiceProvider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NET 9.0All work required to support .NET 9.0area/convertersIssue/Discussion/PR that has to do with ConvertersbugSomething isn't workingunverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions