Skip to content

.NET10-rc1 - XamlSourceGen - Partial method XXX.InitializeComponent()' must have an implementation part because it has accessibility modifiers. #31571

@bcaceiro

Description

@bcaceiro

Description

Using the latest .NET10-rc1 , and trying out the xaml source gen in a new .net MAUI app, I have these errors:

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	CS8795	Partial method '__Type08BAD333D93A1098.InitializeComponent()' must have an implementation part because it has accessibility modifiers.	Maui10Preview7 (net10.0-android)	C:\P\net9-repros\Maui10Preview7\obj\Debug\net10.0-android\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\Resources_Styles_Colors.xaml.sg.cs	26	
Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	CS8795	Partial method '__Type3F0379CBCFA4A406.InitializeComponent()' must have an implementation part because it has accessibility modifiers.	Maui10Preview7 (net10.0-android)	C:\P\net9-repros\Maui10Preview7\obj\Debug\net10.0-android\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\Resources_Styles_Styles.xaml.sg.cs	26	

where the culprits are the Colors.xml files and Styles.xml files ( default )

In order to enable the source gen I applied this:

<MauiXamlInflator>SourceGen</MauiXamlInflator>

On my .csproj

Steps to Reproduce

  1. Clone https://github.com/bcaceiro/net9-repros/tree/main/Maui10Preview7
  2. Build
  3. See errors

Link to public reproduction project repository

https://github.com/bcaceiro/net9-repros/tree/main/Maui10Preview7

Version with bug

10.0.0-rc.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Not using the feature :)))))

Relevant log output

1>------ Build started: Project: Maui10Preview7, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\10.0.100-rc.1.25451.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(345,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>Including assemblies for Hot Reload support
1>C:\P\net9-repros\Maui10Preview7\obj\Debug\net10.0-android\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\Resources_Styles_Colors.xaml.sg.cs(26,24,26,43): error CS8795: Partial method '__Type08BAD333D93A1098.InitializeComponent()' must have an implementation part because it has accessibility modifiers.
1>C:\P\net9-repros\Maui10Preview7\obj\Debug\net10.0-android\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\Resources_Styles_Styles.xaml.sg.cs(26,24,26,43): error CS8795: Partial method '__Type3F0379CBCFA4A406.InitializeComponent()' must have an implementation part because it has accessibility modifiers.
1>Done building project "Maui10Preview7.csproj" -- FAILED.

Metadata

Metadata

Labels

area-xamlXAML, CSS, Triggers, Behaviorss/needs-attentionIssue has more information and needs another lookt/bugSomething isn't workingxsgXaml sourceGen

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions