Skip to content
Open
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
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ dotnet_diagnostic.CA5381.severity = warning
dotnet_diagnostic.CA5384.severity = warning
# Use Rivest–Shamir–Adleman (RSA) Algorithm With Sufficient Key Size
dotnet_diagnostic.CA5385.severity = warning
# Parameter has no matching param tag in the XML comment
dotnet_diagnostic.CS1573.severity = suggestion
dotnet_diagnostic.CS1591.severity = suggestion
# UseIsNullCheck
dotnet_diagnostic.IDE0041.severity = warning
Expand Down
5 changes: 2 additions & 3 deletions src/BuiltInTools/Watch/Context/EnvironmentOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ internal sealed record EnvironmentOptions(
);

public TimeSpan GetProcessCleanupTimeout(bool isHotReloadEnabled)
// If Hot Reload mode is disabled the process is restarted on every file change.
// Waiting for graceful termination would slow down the turn around.
=> ProcessCleanupTimeout ?? (isHotReloadEnabled ? TimeSpan.FromSeconds(5) : TimeSpan.FromSeconds(0));
// Allow sufficient time for the process to exit gracefully and release resources (e.g., network ports).
=> ProcessCleanupTimeout ?? TimeSpan.FromSeconds(5);

private int _uniqueLogId;

Expand Down
22 changes: 0 additions & 22 deletions src/Cli/Microsoft.DotNet.FileBasedPrograms/ExternalHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,3 @@ public static partial bool IsPathFullyQualified(string path)

#endif
}

// https://github.com/dotnet/sdk/issues/51487: Remove usage of GracefulException from the source package
#if FILE_BASED_PROGRAMS_SOURCE_PACKAGE_GRACEFUL_EXCEPTION
internal class GracefulException : Exception
{
public GracefulException()
{
}

public GracefulException(string? message) : base(message)
{
}

public GracefulException(string format, string arg) : this(string.Format(format, arg))
{
}

public GracefulException(string? message, Exception? innerException) : base(message, innerException)
{
}
}
#endif
192 changes: 64 additions & 128 deletions src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Package.Package(in Microsoft.
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Package.Version.get -> string?
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Package.Version.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.Diagnostics.get -> Microsoft.DotNet.FileBasedPrograms.DiagnosticBag
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.Diagnostics.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.DirectiveKind.get -> string!
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.DirectiveKind.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.DirectiveText.get -> string!
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.DirectiveText.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.Info.get -> Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseInfo
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.Info.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.ParseContext() -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.ReportError.get -> Microsoft.DotNet.FileBasedPrograms.ErrorReporter!
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.ReportError.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.SourceFile.get -> Microsoft.DotNet.FileBasedPrograms.SourceFile
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext.SourceFile.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseInfo
Expand All @@ -30,7 +30,7 @@ Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseInfo.Span.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseInfo.TrailingWhiteSpace.get -> Microsoft.DotNet.FileBasedPrograms.WhiteSpaceInfo
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseInfo.TrailingWhiteSpace.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.EnsureProjectFilePath(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.DotNet.FileBasedPrograms.DiagnosticBag diagnostics) -> Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project!
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.EnsureProjectFilePath(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.DotNet.FileBasedPrograms.ErrorReporter! reportError) -> Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project!
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.ExpandedName.get -> string?
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.ExpandedName.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.NameKind
Expand All @@ -53,20 +53,11 @@ Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Sdk.Version.get -> string?
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Sdk.Version.init -> void
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Shebang
Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Shebang.Shebang(in Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseInfo info) -> void
Microsoft.DotNet.FileBasedPrograms.DiagnosticBag
Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.AddError(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.CodeAnalysis.Text.TextSpan textSpan, string! message, System.Exception? inner = null) -> void
Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.AddError<T>(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.CodeAnalysis.Text.TextSpan span, string! message, System.Exception? inner = null) -> T?
Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.Builder.get -> System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.SimpleDiagnostic!>.Builder?
Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.DiagnosticBag() -> void
Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.IgnoreDiagnostics.get -> bool
Microsoft.DotNet.FileBasedPrograms.ErrorReporter
Microsoft.DotNet.FileBasedPrograms.ErrorReporters
Microsoft.DotNet.FileBasedPrograms.ExternalHelpers
Microsoft.DotNet.FileBasedPrograms.ExternalHelpers.ExternalHelpers() -> void
Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers
Microsoft.DotNet.FileBasedPrograms.GracefulException
Microsoft.DotNet.FileBasedPrograms.GracefulException.GracefulException() -> void
Microsoft.DotNet.FileBasedPrograms.GracefulException.GracefulException(string! format, string! arg) -> void
Microsoft.DotNet.FileBasedPrograms.GracefulException.GracefulException(string? message) -> void
Microsoft.DotNet.FileBasedPrograms.GracefulException.GracefulException(string? message, System.Exception? innerException) -> void
Microsoft.DotNet.FileBasedPrograms.MSBuildUtilities
Microsoft.DotNet.FileBasedPrograms.MSBuildUtilities.MSBuildUtilities() -> void
Microsoft.DotNet.FileBasedPrograms.NamedDirectiveComparer
Expand Down Expand Up @@ -104,6 +95,7 @@ Microsoft.DotNet.FileBasedPrograms.WhiteSpaceInfo
Microsoft.DotNet.FileBasedPrograms.WhiteSpaceInfo.LineBreaks -> int
Microsoft.DotNet.FileBasedPrograms.WhiteSpaceInfo.TotalLength -> int
Microsoft.DotNet.FileBasedPrograms.WhiteSpaceInfo.WhiteSpaceInfo() -> void
Microsoft.DotNet.ProjectTools.ProjectLocator
override abstract Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ToString() -> string!
override Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Package.ToString() -> string!
override Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.ToString() -> string!
Expand All @@ -116,23 +108,24 @@ static Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Parse(in Microsoft.Dot
static Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project.Parse(in Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext context) -> Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Project?
static Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Property.Parse(in Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext context) -> Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Property?
static Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Sdk.Parse(in Microsoft.DotNet.FileBasedPrograms.CSharpDirective.ParseContext context) -> Microsoft.DotNet.FileBasedPrograms.CSharpDirective.Sdk?
static Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.Collect(out System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.SimpleDiagnostic!>.Builder! builder) -> Microsoft.DotNet.FileBasedPrograms.DiagnosticBag
static Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.Ignore() -> Microsoft.DotNet.FileBasedPrograms.DiagnosticBag
static Microsoft.DotNet.FileBasedPrograms.DiagnosticBag.ThrowOnFirst() -> Microsoft.DotNet.FileBasedPrograms.DiagnosticBag
static Microsoft.DotNet.FileBasedPrograms.ErrorReporters.CreateCollectingReporter(out System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.SimpleDiagnostic!>.Builder! builder) -> Microsoft.DotNet.FileBasedPrograms.ErrorReporter!
static Microsoft.DotNet.FileBasedPrograms.ExternalHelpers.CombineHashCodes(int value1, int value2) -> int
static Microsoft.DotNet.FileBasedPrograms.ExternalHelpers.GetRelativePath(string! relativeTo, string! path) -> string!
static Microsoft.DotNet.FileBasedPrograms.ExternalHelpers.IsPathFullyQualified(string! path) -> bool
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.CreateTokenizer(Microsoft.CodeAnalysis.Text.SourceText! text) -> Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser!
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.EvaluateDirectives(Microsoft.Build.Execution.ProjectInstance? project, System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!> directives, Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.DotNet.FileBasedPrograms.DiagnosticBag diagnostics) -> System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!>
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.FindDirectives(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, bool reportAllErrors, Microsoft.DotNet.FileBasedPrograms.DiagnosticBag diagnostics) -> System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!>
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.FindLeadingDirectives(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.CodeAnalysis.SyntaxTriviaList triviaList, Microsoft.DotNet.FileBasedPrograms.DiagnosticBag diagnostics, System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!>.Builder? builder) -> void
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.EvaluateDirectives(Microsoft.Build.Execution.ProjectInstance? project, System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!> directives, Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.DotNet.FileBasedPrograms.ErrorReporter! errorReporter) -> System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!>
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.FindDirectives(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, bool reportAllErrors, Microsoft.DotNet.FileBasedPrograms.ErrorReporter! reportError) -> System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!>
static Microsoft.DotNet.FileBasedPrograms.FileLevelDirectiveHelpers.FindLeadingDirectives(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.CodeAnalysis.SyntaxTriviaList triviaList, Microsoft.DotNet.FileBasedPrograms.ErrorReporter! reportError, System.Collections.Immutable.ImmutableArray<Microsoft.DotNet.FileBasedPrograms.CSharpDirective!>.Builder? builder) -> void
static Microsoft.DotNet.FileBasedPrograms.MSBuildUtilities.ConvertStringToBool(string? parameterValue, bool defaultValue = false) -> bool
static Microsoft.DotNet.FileBasedPrograms.Patterns.DisallowedNameCharacters.get -> System.Text.RegularExpressions.Regex!
static Microsoft.DotNet.FileBasedPrograms.Patterns.EscapedCompilerOption.get -> System.Text.RegularExpressions.Regex!
static Microsoft.DotNet.FileBasedPrograms.Patterns.Whitespace.get -> System.Text.RegularExpressions.Regex!
static Microsoft.DotNet.FileBasedPrograms.SourceFile.Load(string! filePath) -> Microsoft.DotNet.FileBasedPrograms.SourceFile
static Microsoft.DotNet.FileBasedPrograms.SourceFile.operator !=(Microsoft.DotNet.FileBasedPrograms.SourceFile left, Microsoft.DotNet.FileBasedPrograms.SourceFile right) -> bool
static Microsoft.DotNet.FileBasedPrograms.SourceFile.operator ==(Microsoft.DotNet.FileBasedPrograms.SourceFile left, Microsoft.DotNet.FileBasedPrograms.SourceFile right) -> bool
static Microsoft.DotNet.ProjectTools.ProjectLocator.TryGetProjectFileFromDirectory(string! projectDirectory, out string? projectFilePath, out string? error) -> bool
static readonly Microsoft.DotNet.FileBasedPrograms.ErrorReporters.IgnoringReporter -> Microsoft.DotNet.FileBasedPrograms.ErrorReporter!
static readonly Microsoft.DotNet.FileBasedPrograms.NamedDirectiveComparer.Instance -> Microsoft.DotNet.FileBasedPrograms.NamedDirectiveComparer!
virtual Microsoft.DotNet.FileBasedPrograms.ErrorReporter.Invoke(Microsoft.DotNet.FileBasedPrograms.SourceFile sourceFile, Microsoft.CodeAnalysis.Text.TextSpan textSpan, string! message) -> void
~override Microsoft.DotNet.FileBasedPrograms.SourceFile.Equals(object obj) -> bool
~override Microsoft.DotNet.FileBasedPrograms.SourceFile.ToString() -> string
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
<!-- Remove once https://github.com/NuGet/Home/issues/8583 is fixed -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
<EnableDefaultItems>false</EnableDefaultItems>
<DefineConstants>$(DefineConstants);FILE_BASED_PROGRAMS_SOURCE_PACKAGE_BUILD;FILE_BASED_PROGRAMS_SOURCE_PACKAGE_GRACEFUL_EXCEPTION</DefineConstants>
<DefineConstants>$(DefineConstants);FILE_BASED_PROGRAMS_SOURCE_PACKAGE_BUILD</DefineConstants>
<!-- Files must individually enable nullable in source packages -->
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" />
<PackageReference Include="Microsoft.CodeAnalysis.Contracts" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
Expand Down
53 changes: 53 additions & 0 deletions src/Cli/Microsoft.DotNet.FileBasedPrograms/ProjectLocator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable enable

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Microsoft.DotNet.FileBasedPrograms;

namespace Microsoft.DotNet.ProjectTools;

internal static class ProjectLocator
{
public static bool TryGetProjectFileFromDirectory(string projectDirectory, [NotNullWhen(true)] out string? projectFilePath, [NotNullWhen(false)] out string? error)
{
projectFilePath = null;
error = null;

DirectoryInfo? dir;
try
{
dir = new DirectoryInfo(projectDirectory);
}
catch (ArgumentException)
{
dir = null;
}

if (dir == null || !dir.Exists)
{
error = string.Format(FileBasedProgramsResources.CouldNotFindProjectOrDirectory, projectDirectory);
return false;
}

FileInfo[] files = dir.GetFiles("*proj");
if (files.Length == 0)
{
error = string.Format(FileBasedProgramsResources.CouldNotFindAnyProjectInDirectory, projectDirectory);
return false;
}

if (files.Length > 1)
{
error = string.Format(FileBasedProgramsResources.MoreThanOneProjectInDirectory, projectDirectory);
return false;
}

projectFilePath = files.First().FullName;
return true;
}
}
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override int Execute()
string projectFilePath;
if (!File.Exists(fileOrDirectory))
{
projectFilePath = MsbuildProject.GetProjectFileFromDirectory(fileOrDirectory).FullName;
projectFilePath = MsbuildProject.GetProjectFileFromDirectory(fileOrDirectory);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override int Execute()
string projectFilePath;
if (!File.Exists(fileOrDirectory))
{
projectFilePath = MsbuildProject.GetProjectFileFromDirectory(fileOrDirectory).FullName;
projectFilePath = MsbuildProject.GetProjectFileFromDirectory(fileOrDirectory);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public override int Execute()

// Find directives (this can fail, so do this before creating the target directory).
var sourceFile = SourceFile.Load(file);
var diagnostics = DiagnosticBag.ThrowOnFirst();
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: !_force, diagnostics);
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: !_force, VirtualProjectBuildingCommand.ThrowingReporter);

// Create a project instance for evaluation.
var projectCollection = new ProjectCollection();
Expand All @@ -46,7 +45,7 @@ public override int Execute()
var projectInstance = command.CreateProjectInstance(projectCollection);

// Evaluate directives.
directives = FileLevelDirectiveHelpers.EvaluateDirectives(projectInstance, directives, sourceFile, diagnostics);
directives = VirtualProjectBuildingCommand.EvaluateDirectives(projectInstance, directives, sourceFile, VirtualProjectBuildingCommand.ThrowingReporter);
command.Directives = directives;
projectInstance = command.CreateProjectInstance(projectCollection);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override int Execute()

return Path.GetRelativePath(
msbuildProj.ProjectRootElement.FullPath,
MsbuildProject.GetProjectFileFromDirectory(fullPath).FullName
MsbuildProject.GetProjectFileFromDirectory(fullPath)
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Run/Api/RunApiCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public sealed class GetProject : RunApiInput
public override RunApiOutput Execute()
{
var sourceFile = SourceFile.Load(EntryPointFileFullPath);
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: true, DiagnosticBag.Collect(out var diagnostics));
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: true, ErrorReporters.CreateCollectingReporter(out var diagnostics));
string artifactsPath = ArtifactsPath ?? VirtualProjectBuildingCommand.GetArtifactsPath(EntryPointFileFullPath);

var csprojWriter = new StringWriter();
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Run/FileBasedAppSourceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ImmutableArray<CSharpDirective> Directives
{
if (field.IsDefault)
{
field = FileLevelDirectiveHelpers.FindDirectives(SourceFile, reportAllErrors: false, DiagnosticBag.Ignore());
field = FileLevelDirectiveHelpers.FindDirectives(SourceFile, reportAllErrors: false, ErrorReporters.IgnoringReporter);
Debug.Assert(!field.IsDefault);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private bool TrySelectTargetFrameworkForFileBasedProject()
private static string[]? GetTargetFrameworksFromSourceFile(string sourceFilePath)
{
var sourceFile = SourceFile.Load(sourceFilePath);
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: false, DiagnosticBag.Ignore());
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: false, ErrorReporters.IgnoringReporter);

var targetFrameworksDirective = directives.OfType<CSharpDirective.Property>()
.FirstOrDefault(p => string.Equals(p.Name, "TargetFrameworks", StringComparison.OrdinalIgnoreCase));
Expand Down
Loading
Loading