dotnet/roslyn

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

開放

#82,351 建立於 2026年2月10日

 (8 則留言) (0 個反應) (1 位負責人)C# (4,257 個分叉)batch import
Area-CompilersConcept-Diagnostic ClarityFeature - Extension Everythinghelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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"
	}
}

貢獻者指南