dotnet/roslyn

improve CS9293 message to show it's about "static"

Open

#82.351 aperta il 10 feb 2026

Vedi su GitHub
 (8 commenti) (0 reazioni) (1 assegnatario)C# (4257 fork)batch import
Area-CompilersConcept-Diagnostic ClarityFeature - Extension Everythinghelp wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

i was just moving an extension method into an extension block manually and forgot to remove the static modifier, and got greeted with

error CS9293: Cannot use extension parameter 'IFormApplic formApplic' in this context.

i suggest the wording should include the word "static" so that it's easier to spot that - context is kinda a little too general a term, i think.

here's some code ... for context:

public static class Extensions
{	
	extension(int number)
	{
		public static void M() => Console.WriteLine(number);
		// Error message: "cannot use extension parameter (int number) in this context"
		// maybe better : "cannot use extension parameter (int number) in static context"
	}
}

Guida contributor