Skip to content

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented Sep 10, 2025

Addresses part of #78961 ("we should probably have better error recovery in older LangVer so that we can offer a dedicated diagnostic to trigger UpgradeProject")
Relates to test plan #76130

@jcouv jcouv self-assigned this Sep 10, 2025
@jcouv jcouv added Area-Compilers Feature - Extension Everything The extension everything feature labels Sep 10, 2025
diagnostics.Add(ErrorCode.ERR_MemberNeedsType, location);
if (syntax.Identifier.Text == "extension")
{
bool reported = !MessageID.IDS_FeatureExtensions.CheckFeatureAvailability(diagnostics, syntax);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 I intentionally didn't introduce a dedicated error message for this niche scenario, where the user intends to write a constructor but accidentally named it "extension" or should have named the type "extension". I think it's safe to assume the user wants an extension block

@jcouv jcouv marked this pull request as ready for review September 10, 2025 18:24
@jcouv jcouv requested a review from a team as a code owner September 10, 2025 18:24
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 1)

UsingTree("""
class C
var src = """
static class C
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the langver error not given if the containing class is not static?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, but you'd also get an error (extension must be inside a static class) which isn't relevant to this test

@jcouv jcouv requested a review from jjonescz September 11, 2025 09:28
@jcouv jcouv merged commit 7c0f70d into dotnet:main Sep 11, 2025
25 checks passed
@jcouv jcouv deleted the extensions-langver branch September 11, 2025 09:33
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 11, 2025
333fred added a commit to 333fred/roslyn that referenced this pull request Sep 11, 2025
* upstream/main: (233 commits)
  Extensions: add SyntaxGenerator support and AssociatedExtensionImplementation API (dotnet#80170)
  Fix error when hoisting a non-ref call (dotnet#80138)
  Ensure that refkinds are rewritten for complex methods (dotnet#79916)
  Revert
  Do not go through the workspace to access services
  DefiniteAssignmentPass.MarkFieldsUsed - avoid infinite recursion due to generic substitution (dotnet#80135)
  Reduce allocations in AnalyzerDriver.TryExecuteSymbolEndActions (dotnet#79855)
  RefSafetyAnalysis: Fix handling of nested deconstruction utilizing modern extensions (dotnet#80231)
  Extensions: adjust rewriting of anonymous type property symbols (dotnet#80211)
  Extensions: Move public APIs into INamedTypeSymbol (dotnet#80230)
  Extensions: improve error recovery in older language versions (dotnet#80206)
  Fall back to `dotnet exec` if apphost does not exist (dotnet#80153)
  Update dependencies from https://github.com/dotnet/dotnet build 282708 (dotnet#80228)
  Add a workaround for microsoft/vs-mef#620
  Revert "FailFast if the MEF composition is clearly broken"
  switch from windows combobox to visualstudio combobox (dotnet#80219)
  Update System.Text.Json in packages which use 4.12 Roslyn (dotnet#80197)
  add flags to unblock CI (dotnet#80222)
  Move static members to another type - qualifies static member references in the moved members (dotnet#80178)
  Fix broken link for C# 14 lambda parameter modifiers
  ...
@akhera99 akhera99 modified the milestones: Next, 18.0 P1, 18.0 P2 Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Extension Everything The extension everything feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants