Skip to content

File-based apps: Add support for #:ref directive - #83985

Merged
RikkiGibson merged 5 commits into
dotnet:mainfrom
RikkiGibson:fba-update
Aug 5, 2026
Merged

File-based apps: Add support for #:ref directive#83985
RikkiGibson merged 5 commits into
dotnet:mainfrom
RikkiGibson:fba-update

Conversation

@RikkiGibson

@RikkiGibson RikkiGibson commented Jun 2, 2026

Copy link
Copy Markdown
Member
  • Adds a classification test
  • Adds a completion provider
Microsoft Reviewers: Open in CodeFlow

Comment thread src/Features/CSharp/Portable/SyncedSource/commitid.txt Outdated
@jjonescz jjonescz added the Feature - Run File #: and #! directives and file-based C# programs label Jun 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40d9d26f-af18-47fd-9287-1b798322acf9

# Conflicts:
#	src/Features/CSharp/Portable/SyncedSource/commitid.txt
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.cs.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.de.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.es.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.fr.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.it.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.ja.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.ko.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.pl.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.pt-BR.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.ru.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.tr.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.zh-Hans.xlf
#	src/Workspaces/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.zh-Hant.xlf
@RikkiGibson
RikkiGibson marked this pull request as ready for review August 4, 2026 22:11
@RikkiGibson
RikkiGibson requested a review from a team as a code owner August 4, 2026 22:11
Copilot AI review requested due to automatic review settings August 4, 2026 22:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds IDE support for the #:ref directive in C# file-based programs by introducing a dedicated completion provider, adding syntactic classification coverage, and wiring up the related user-facing resource strings (including localized .xlf entries).

Changes:

  • Add RefAppDirectiveCompletionProvider to offer #:ref directive completion and .cs path completion for file-based programs.
  • Extend completion provider ordering tests and add directive-specific completion tests for #:ref.
  • Add syntactic classification coverage for #:ref and add new resource strings + localized .xlf entries.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf Adds new localized string entries for the #:ref directive description and placeholder.
src/Features/CSharp/Portable/CSharpFeaturesResources.resx Adds the base resource strings for #:ref directive placeholder and description.
src/Features/CSharp/Portable/Completion/CompletionProviders/LastBuiltInCompletionProvider.cs Updates completion provider ordering so the built-in marker comes after the new RefAppDirectiveCompletionProvider.
src/Features/CSharp/Portable/Completion/CompletionProviders/FileBasedPrograms/RefAppDirectiveCompletionProvider.cs Introduces the new completion provider for the #:ref directive and .cs file path completion.
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/CompletionProviderOrderTests.cs Updates expected built-in completion provider order to include the new provider.
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/AppDirectiveCompletionProviderTests.cs Adds completion tests specifically for #:ref path recommendations and .cs-only filtering.
src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_FileBasedApps.cs Adds a syntactic classification test covering #:ref.
Suppressed comments (1)

src/Features/CSharp/Portable/CSharpFeaturesResources.resx:638

  • Adds_a_file_based_app_reference currently says "References another file-based app as a library." The #:ref spec describes this as referencing another .cs file as a separate (virtual) project reference, and the referenced file can still default to OutputType=Exe unless overridden. Consider rewording this string to describe a project reference to another .cs file-based program instead of implying it’s always a library.
  <data name="Adds_a_file_based_app_reference" xml:space="preserve">
    <value>References another file-based app as a library.</value>
  </data>

Comment on lines +632 to +635
<data name="Ref_directive_file_path" xml:space="preserve">
<value>path</value>
<comment>'path' is a placeholder for a file path in a directive like '#:ref path'.</comment>
</data>
@jjonescz
jjonescz requested a review from a team August 5, 2026 08:55
@RikkiGibson

Copy link
Copy Markdown
Member Author

CI analysis for build 1540027:

  • Test_Windows_CoreClr_RuntimeAsync_Debug failed CommandLineTests.TestSuppression_CompilerSyntaxParseError_SuppressWarningCaughtDuringParsingStage(skipAnalyzers: false) because pool validation found an ArrayBuilder<ReadOnlyMemory<char>> allocated by MetadataHelpers was not returned.
  • The log does not report an underlying exception from the compiler/analyzer path; the only surfaced exception is the pool validator's failure after the test. Therefore we cannot yet identify what interrupted cleanup or claim that the broad, closed pool-leak KBE [Known Build Error] Pool leak detected #83972 covers this instance.
  • Test_Windows_CoreClr_IOperation_Debug and Test_Windows_CoreClr_Debug dead-lettered in Helix with artificial exit code -1, so those are infrastructure failures.
  • The immediately preceding build passed at the same merge SHA.

Retrying roslyn-CI and watching for recurrence of the pool leak. If it recurs, we should capture the repeated evidence and file a specific Known Build Error issue rather than matching the generic pool-leak issue.

@RikkiGibson

Copy link
Copy Markdown
Member Author

/azp run roslyn-CI

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@RikkiGibson
RikkiGibson enabled auto-merge (squash) August 5, 2026 20:13
@RikkiGibson
RikkiGibson merged commit 7716b3b into dotnet:main Aug 5, 2026
24 of 25 checks passed
@jjonescz jjonescz added this to the 18.11 milestone Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Feature - Run File #: and #! directives and file-based C# programs VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants