Skip to content

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

Draft
RikkiGibson wants to merge 4 commits into
dotnet:mainfrom
RikkiGibson:fba-update
Draft

File-based apps: Add support for #:ref directive#83985
RikkiGibson wants to merge 4 commits into
dotnet:mainfrom
RikkiGibson:fba-update

Conversation

@RikkiGibson
Copy link
Copy Markdown
Member

@RikkiGibson RikkiGibson commented Jun 2, 2026

  • Updates the SyncedSource, to use the bits including #:ref, so that just having a #:ref at all doesn't report an error.
  • Adds a classification test
  • Adds a completion provider.

Note: the end to end scenario doesn't work yet. Right now the problem I'm seeing is, when we DTB the project which contains the #:ref, it gets this warning:

2026-06-02 15:36:01.331 [warning] [initialized] [LanguageServerProjectLoader] Warning while loading c:\Users\rikki\src\damian-fba-samples\flat\webapi.tests.csproj: The referenced project c:\Users\rikki\src\damian-fba-samples\flat\webapi.cs.csproj does not exist.

The project that we are getting from run-api looks like this:

<Project>
  <PropertyGroup>
    <IncludeProjectNameInArtifactsPaths>false</IncludeProjectNameInArtifactsPaths>
    <ArtifactsPath>/artifacts</ArtifactsPath>
    <AssemblyName>webapi.tests</AssemblyName>
    <RootNamespace>$(AssemblyName)</RootNamespace>
    <PublishDir>artifacts/$(AssemblyName)</PublishDir>
    <PackageOutputPath>artifacts/$(AssemblyName)</PackageOutputPath>
    <FileBasedProgram>true</FileBasedProgram>
    <EntryPointFilePath>C:\Users\rikki\src\damian-fba-samples\flat\webapi.tests.cs</EntryPointFilePath>
    <FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content</FileBasedProgramsItemMapping>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
    <DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
    <EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
    <EnableDefaultNoneItems>false</EnableDefaultNoneItems>
    <OutputType>Exe</OutputType>
    <TargetFramework>net11.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishAot>true</PublishAot>
    <PackAsTool>true</PackAsTool>
  </PropertyGroup>
  <ItemGroup>
    <Clean Include="/artifacts/*" />
  </ItemGroup>
  <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
  <PropertyGroup>
    <PublishAot>false</PublishAot>
    <ExperimentalFileBasedProgramEnableRefDirective>true</ExperimentalFileBasedProgramEnableRefDirective>
    <RestoreUseStaticGraphEvaluation>false</RestoreUseStaticGraphEvaluation>
    <Features>$(Features);FileBasedProgram</Features>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="xunit.v3" Version="3.2.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.8" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="C:\Users\rikki\src\damian-fba-samples\flat\webapi.cs.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="C:\Users\rikki\src\damian-fba-samples\flat\webapi.tests.cs" Exclude="@(Compile)" />
  </ItemGroup>
  <ItemGroup>
    <RuntimeHostConfigurationOption Include="EntryPointFilePath" Value="C:\Users\rikki\src\damian-fba-samples\flat\webapi.tests.cs" />
    <RuntimeHostConfigurationOption Include="EntryPointFileDirectoryPath" Value="C:\Users\rikki\src\damian-fba-samples\flat" />
  </ItemGroup>
  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>

We need to figure out the right layer to make a change, so that we "do the right thing" with a reference like webapi.cs.csproj. It's not obvious to me how to address the problem at the moment.

Microsoft Reviewers: Open in CodeFlow

@@ -1 +1 @@
b6ecfca4772c223907a0fe13b0ab944a8e197d53 No newline at end of file
2a4129e11d1a6ffecc39ee9098e4027689c0c768 No newline at end of file
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

reminder that this is just copying sources over from dotnet/sdk, in-depth review is not needed.

@jjonescz jjonescz added the Feature - Run File #: and #! directives and file-based C# programs label Jun 3, 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.

2 participants