Skip to content

Commit 06dc8f5

Browse files
authored
Update FileBasedPrograms package (#81879)
1 parent f40609b commit 06dc8f5

20 files changed

+256
-138
lines changed

eng/Version.Details.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This file should be imported by eng/Versions.props
1111
<MicrosoftCodeAnalysisAnalyzerUtilitiesPackageVersion>5.3.0-2.25625.1</MicrosoftCodeAnalysisAnalyzerUtilitiesPackageVersion>
1212
<MicrosoftNetCompilersToolsetPackageVersion>5.3.0-2.25625.1</MicrosoftNetCompilersToolsetPackageVersion>
1313
<!-- dotnet/dotnet dependencies -->
14-
<MicrosoftDotNetFileBasedProgramsPackageVersion>10.0.200-preview.0.25556.104</MicrosoftDotNetFileBasedProgramsPackageVersion>
14+
<MicrosoftDotNetFileBasedProgramsPackageVersion>11.0.100-alpha.1.26055.109</MicrosoftDotNetFileBasedProgramsPackageVersion>
1515
<RoslynDiagnosticsAnalyzersPackageVersion>5.3.0-2.26055.102</RoslynDiagnosticsAnalyzersPackageVersion>
1616
<SystemCommandLinePackageVersion>3.0.0-alpha.1.26055.102</SystemCommandLinePackageVersion>
1717
<!-- dotnet/runtime dependencies -->

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@
139139
<Uri>https://github.com/dotnet/arcade-services</Uri>
140140
<Sha>8b5a2ffee4f4097893b7fc670f7d86d84c8c841f</Sha>
141141
</Dependency>
142-
<Dependency Name="Microsoft.DotNet.FileBasedPrograms" Version="10.0.200-preview.0.25556.104">
142+
<Dependency Name="Microsoft.DotNet.FileBasedPrograms" Version="11.0.100-alpha.1.26055.109">
143143
<Uri>https://github.com/dotnet/dotnet</Uri>
144-
<Sha>cc979c006a27c251782bee45e8887213c24bf806</Sha>
144+
<Sha>1f7265970fd1148d2aa27cfc179393d1dcfd789e</Sha>
145145
</Dependency>
146146
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.0-preview.25375.1">
147147
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>

src/Features/CSharp/Portable/Diagnostics/Analyzers/FileBasedPrograms/FileLevelDirectiveDiagnosticAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ protected override void InitializeWorker(AnalysisContext context)
4949
// Therefore, the analyzer only deals with the directives on the first token.
5050
// Console.WriteLine("Hello World!");
5151
// #:property foo=bar // error CS9297: '#:' directives cannot be after first token in file
52-
var diagnosticBag = DiagnosticBag.Collect(out var diagnosticsBuilder);
52+
var errorReporter = ErrorReporters.CreateCollectingReporter(out var diagnosticsBuilder);
5353
FileLevelDirectiveHelpers.FindLeadingDirectives(
5454
new SourceFile(tree.FilePath, tree.GetText(cancellationToken)),
5555
root.GetLeadingTrivia(),
56-
diagnosticBag,
56+
errorReporter,
5757
builder: null);
5858

5959
foreach (var simpleDiagnostic in diagnosticsBuilder)

src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms/ExternalHelpers.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,3 @@ public static partial bool IsPathFullyQualified(string path)
4040

4141
#endif
4242
}
43-
44-
// https://github.com/dotnet/sdk/issues/51487: Remove usage of GracefulException from the source package
45-
#if FILE_BASED_PROGRAMS_SOURCE_PACKAGE_GRACEFUL_EXCEPTION
46-
internal class GracefulException : Exception
47-
{
48-
public GracefulException()
49-
{
50-
}
51-
52-
public GracefulException(string? message) : base(message)
53-
{
54-
}
55-
56-
public GracefulException(string format, string arg) : this(string.Format(format, arg))
57-
{
58-
}
59-
60-
public GracefulException(string? message, Exception? innerException) : base(message, innerException)
61-
{
62-
}
63-
}
64-
#endif

src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms/FileBasedProgramsResources.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,7 @@
169169
<value>Unrecognized directive '{0}'.</value>
170170
<comment>{0} is the directive name like 'package' or 'sdk'.</comment>
171171
</data>
172-
</root>
172+
<data name="EmptyTempPath" xml:space="preserve">
173+
<value>Unable to determine a temporary directory path. Consider configuring the TEMP environment variable on Windows or local app data folder on Unix.</value>
174+
</data>
175+
</root>

src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms/FileLevelDirectiveHelpers.cs

Lines changed: 129 additions & 110 deletions
Large diffs are not rendered by default.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#nullable enable
5+
6+
using System;
7+
using System.Diagnostics.CodeAnalysis;
8+
using System.IO;
9+
using System.Linq;
10+
using Microsoft.DotNet.FileBasedPrograms;
11+
12+
namespace Microsoft.DotNet.ProjectTools;
13+
14+
internal static class ProjectLocator
15+
{
16+
public static bool TryGetProjectFileFromDirectory(string projectDirectory, [NotNullWhen(true)] out string? projectFilePath, [NotNullWhen(false)] out string? error)
17+
{
18+
projectFilePath = null;
19+
error = null;
20+
21+
DirectoryInfo? dir;
22+
try
23+
{
24+
dir = new DirectoryInfo(projectDirectory);
25+
}
26+
catch (ArgumentException)
27+
{
28+
dir = null;
29+
}
30+
31+
if (dir == null || !dir.Exists)
32+
{
33+
error = string.Format(FileBasedProgramsResources.CouldNotFindProjectOrDirectory, projectDirectory);
34+
return false;
35+
}
36+
37+
FileInfo[] files = dir.GetFiles("*proj");
38+
if (files.Length == 0)
39+
{
40+
error = string.Format(FileBasedProgramsResources.CouldNotFindAnyProjectInDirectory, projectDirectory);
41+
return false;
42+
}
43+
44+
if (files.Length > 1)
45+
{
46+
error = string.Format(FileBasedProgramsResources.MoreThanOneProjectInDirectory, projectDirectory);
47+
return false;
48+
}
49+
50+
projectFilePath = files.First().FullName;
51+
return true;
52+
}
53+
}

src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Features/CSharp/Portable/SyncedSource/FileBasedPrograms/xlf/FileBasedProgramsResources.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)