Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ private CSharpDirective() { }
"sdk" => Sdk.Parse(errors, sourceFile, span, directiveKind, directiveText),
"property" => Property.Parse(errors, sourceFile, span, directiveKind, directiveText),
"package" => Package.Parse(errors, sourceFile, span, directiveKind, directiveText),
"project" => Project.Parse(errors, sourceFile, span, directiveText),
"project" => Project.Parse(errors, sourceFile, span, directiveKind, directiveText),
_ => ReportError<Named>(errors, sourceFile, span, string.Format(CliCommandStrings.UnrecognizedDirective, directiveKind, sourceFile.GetLocationString(span))),
};
}
Expand Down Expand Up @@ -1213,8 +1213,13 @@ public sealed class Project : Named
{
private Project() { }

public static Project Parse(ImmutableArray<SimpleDiagnostic>.Builder? errors, SourceFile sourceFile, TextSpan span, string directiveText)
public static new Project? Parse(ImmutableArray<SimpleDiagnostic>.Builder? errors, SourceFile sourceFile, TextSpan span, string directiveKind, string directiveText)
{
if (directiveText.IsWhiteSpace())
{
return ReportError<Project?>(errors, sourceFile, span, string.Format(CliCommandStrings.MissingDirectiveName, directiveKind, sourceFile.GetLocationString(span)));
}

try
{
// If the path is a directory like '../lib', transform it to a project file path like '../lib/lib.csproj'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ public void Directives_Empty()

[Theory, CombinatorialData]
public void Directives_EmptyName(
[CombinatorialValues("sdk", "property", "package")] string directive,
[CombinatorialValues("sdk", "property", "package", "project")] string directive,
Copy link
Member

Choose a reason for hiding this comment

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

A virtual project will still be produced in this case right? I guess we also do that for the empty name cases for the other directives listed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

In case of run-api, yes, that one collects all errors and produces the virtual project file (without directives that have errors), there are tests for that in general (Api_Diagnostic_*), albeit not this particular case. In case of other commands like run, the first error makes the whole command fail, so there is no virtual project produced.

[CombinatorialValues(" ", "")] string value)
{
VerifyConversionThrows(
Expand Down
Loading