Skip to content

Commit 4284ea1

Browse files
[VMR] Codeflow 2f666ec-2f666ec
[[ commit created by automation ]]
1 parent 2f666ec commit 4284ea1

File tree

91 files changed

+495
-475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+495
-475
lines changed

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
numbers of the shared frameworks. -->
104104
<MicrosoftWindowsDesktopAppRuntimePackageVersion>$(MicrosoftNETCoreAppRefPackageVersion)</MicrosoftWindowsDesktopAppRuntimePackageVersion>
105105
<MicrosoftWindowsDesktopAppRefPackageVersion>$(MicrosoftNETCoreAppRefPackageVersion)</MicrosoftWindowsDesktopAppRefPackageVersion>
106-
<MicrosoftNETSdkWindowsDesktopPackageVersion>$(MicrosoftNETCorePlatformsPackageVersion)</MicrosoftNETSdkWindowsDesktopPackageVersion>
107106
<MicrosoftWindowsDesktopAppInternalPackageVersion>$(MicrosoftNETCorePlatformsPackageVersion)</MicrosoftWindowsDesktopAppInternalPackageVersion>
108107

109108
<HostFxrVersion>$(MicrosoftNETCoreAppRuntimePackageVersion)</HostFxrVersion>

src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,18 @@ public static FormatOptions ParseVerbosityOption(this ParseResult parseResult, F
164164

165165
public static FormatOptions ParseCommonOptions(this ParseResult parseResult, FormatOptions formatOptions, ILogger logger)
166166
{
167-
if (parseResult.GetResult(NoRestoreOption) is not null)
167+
if (parseResult.GetValue(NoRestoreOption))
168168
{
169169
formatOptions = formatOptions with { NoRestore = true };
170170
}
171171

172-
if (parseResult.GetResult(VerifyNoChanges) is not null)
172+
if (parseResult.GetValue(VerifyNoChanges))
173173
{
174174
formatOptions = formatOptions with { ChangesAreErrors = true };
175175
formatOptions = formatOptions with { SaveFormattedFiles = false };
176176
}
177177

178-
if (parseResult.GetResult(IncludeGeneratedOption) is not null)
178+
if (parseResult.GetValue(IncludeGeneratedOption))
179179
{
180180
formatOptions = formatOptions with { IncludeGeneratedFiles = true };
181181
}
@@ -300,7 +300,7 @@ public static FormatOptions ParseWorkspaceOptions(this ParseResult parseResult,
300300

301301
if (parseResult.GetValue<string>(SlnOrProjectArgument) is string { Length: > 0 } slnOrProject)
302302
{
303-
if (parseResult.GetResult(FolderOption) is not null)
303+
if (parseResult.GetValue(FolderOption))
304304
{
305305
formatOptions = formatOptions with { WorkspaceFilePath = slnOrProject };
306306
formatOptions = formatOptions with { WorkspaceType = WorkspaceType.Folder };

src/BuiltInTools/dotnet-format/Commands/FormatWhitespaceCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ internal static Command GetCommand()
2828
internal static void EnsureFolderNotSpecifiedWithNoRestore(CommandResult symbolResult)
2929
{
3030
var folder = symbolResult.GetValue(FolderOption);
31-
var noRestore = symbolResult.GetResult(NoRestoreOption);
32-
if (folder && noRestore != null)
31+
var noRestore = symbolResult.GetValue(NoRestoreOption);
32+
if (folder && noRestore)
3333
{
3434
symbolResult.AddError(Resources.Cannot_specify_the_folder_option_with_no_restore);
3535
}

src/BuiltInTools/dotnet-format/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class Program
99
private static async Task<int> Main(string[] args)
1010
{
1111
var rootCommand = RootFormatCommand.GetCommand();
12-
return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None);
12+
return await rootCommand.Parse(args).InvokeAsync(null, CancellationToken.None);
1313
}
1414
}
1515
}

src/BuiltInTools/dotnet-watch/CommandLine/CommandLineOptions.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal sealed class CommandLineOptions
4343

4444
verboseOption.Validators.Add(v =>
4545
{
46-
if (v.GetResult(quietOption) is not null && v.GetResult(verboseOption) is not null)
46+
if (v.GetValue(quietOption) && v.GetValue(verboseOption))
4747
{
4848
v.AddError(Resources.Error_QuietAndVerboseSpecified);
4949
}
@@ -90,17 +90,14 @@ internal sealed class CommandLineOptions
9090
var rootCommandInvoked = false;
9191
rootCommand.SetAction(parseResult => rootCommandInvoked = true);
9292

93-
var cliConfig = new CommandLineConfiguration(rootCommand)
93+
ParserConfiguration parseConfig = new()
9494
{
95-
Output = output,
96-
Error = output,
97-
9895
// To match dotnet command line parsing (see https://github.com/dotnet/sdk/blob/4712b35b94f2ad672e69ec35097cf86fc16c2e5e/src/Cli/dotnet/Parser.cs#L169):
9996
EnablePosixBundling = false,
10097
};
10198

10299
// parse without forwarded options first:
103-
var parseResult = rootCommand.Parse(args, cliConfig);
100+
var parseResult = rootCommand.Parse(args, parseConfig);
104101
if (ReportErrors(parseResult, reporter))
105102
{
106103
errorCode = 1;
@@ -118,15 +115,19 @@ internal sealed class CommandLineOptions
118115
}
119116

120117
// reparse with forwarded options:
121-
parseResult = rootCommand.Parse(args, cliConfig);
118+
parseResult = rootCommand.Parse(args, parseConfig);
122119
if (ReportErrors(parseResult, reporter))
123120
{
124121
errorCode = 1;
125122
return null;
126123
}
127124

128125
// invoke to execute default actions for displaying help
129-
errorCode = parseResult.Invoke();
126+
errorCode = parseResult.Invoke(new()
127+
{
128+
Output = output,
129+
Error = output
130+
});
130131
if (!rootCommandInvoked)
131132
{
132133
// help displayed:
@@ -192,9 +193,15 @@ private static IReadOnlyList<string> GetCommandArguments(
192193
continue;
193194
}
194195

196+
// skip Option<bool> zero-arity options with an implicit optionresult - these weren't actually specified by the user:
197+
if (optionResult.Option is Option<bool> boolOpt && boolOpt.Arity.Equals(ArgumentArity.Zero) && optionResult.Implicit)
198+
{
199+
continue;
200+
}
201+
195202
// Some options _may_ be computed or have defaults, so not all may have an IdentifierToken.
196-
// For those that do not, use the Option's Name instead.
197-
var optionNameToForward = optionResult.IdentifierToken?.Value ?? optionResult.Option.Name;
203+
// For those that do not, use the Option's Name instead.
204+
var optionNameToForward = optionResult.IdentifierToken?.Value ?? optionResult.Option.Name;
198205
if (optionResult.Tokens.Count == 0 && !optionResult.Implicit)
199206
{
200207
arguments.Add(optionNameToForward);

src/BuiltInTools/dotnet-watch/HotReload/IncrementalMSBuildWorkspace.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal class IncrementalMSBuildWorkspace : Workspace
1818
public IncrementalMSBuildWorkspace(IReporter reporter)
1919
: base(MSBuildMefHostServices.DefaultServices, WorkspaceKind.MSBuild)
2020
{
21+
#pragma warning disable CS0618 // https://github.com/dotnet/sdk/issues/49725
2122
WorkspaceFailed += (_sender, diag) =>
2223
{
2324
// Report both Warning and Failure as warnings.
@@ -26,6 +27,7 @@ public IncrementalMSBuildWorkspace(IReporter reporter)
2627
// https://github.com/dotnet/roslyn/issues/75170
2728
reporter.Warn($"msbuild: {diag.Diagnostic}", "⚠");
2829
};
30+
#pragma warning restore CS0618
2931

3032
_reporter = reporter;
3133
}

src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildArgs.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ private MSBuildArgs(ReadOnlyDictionary<string, string>? properties, ReadOnlyDict
4545
/// </summary>
4646
public List<string> OtherMSBuildArgs { get; }
4747

48+
/// <summary>
49+
/// Ensures that when we do our MSBuild-property re-parses we parse in the same way as the dotnet CLI's parser.
50+
/// </summary>
51+
private static readonly ParserConfiguration _analysisParsingConfiguration = new()
52+
{
53+
EnablePosixBundling = false
54+
};
55+
4856
/// <summary>
4957
/// Takes all of the unstructured properties and arguments that have been accrued from the command line
5058
/// processing of the SDK and returns a structured set of MSBuild arguments grouped by purpose.
@@ -58,12 +66,8 @@ public static MSBuildArgs AnalyzeMSBuildArguments(IEnumerable<string> forwardedA
5866
{
5967
fakeCommand.Options.Add(option);
6068
}
61-
62-
var propertyParsingConfiguration = new CommandLineConfiguration(fakeCommand)
63-
{
64-
EnablePosixBundling = false
65-
};
66-
var parseResult = propertyParsingConfiguration.Parse([..forwardedAndUserFacingArgs]);
69+
;
70+
var parseResult = fakeCommand.Parse([.. forwardedAndUserFacingArgs], _analysisParsingConfiguration);
6771
var globalProperties = parseResult.GetResult("--property") is OptionResult propResult ? propResult.GetValueOrDefault<ReadOnlyDictionary<string, string>?>() : null;
6872
var restoreProperties = parseResult.GetResult("--restoreProperty") is OptionResult restoreResult ? restoreResult.GetValueOrDefault<ReadOnlyDictionary<string, string>?>() : null;
6973
var requestedTargets = parseResult.GetResult("--target") is OptionResult targetResult ? targetResult.GetValueOrDefault<string[]?>() : null;

src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
for Mac and other VS scenarios. During source-build, we only have access to
3333
the latest version, which targets NetCurrent. -->
3434
<PropertyGroup>
35-
<MSBuildPathInPackage>$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net9.0\MSBuild.dll</MSBuildPathInPackage>
35+
<MSBuildPathInPackage>$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net10.0\MSBuild.dll</MSBuildPathInPackage>
3636
<MSBuildPathInPackage Condition="'$(DotNetBuildSourceOnly)' == 'true' and !Exists($(MSBuildPathInPackage))">$(PkgMicrosoft_Build_Runtime)\contentFiles\any\$(NetCurrent)\MSBuild.dll</MSBuildPathInPackage>
3737
</PropertyGroup>
3838
<Error Condition="!Exists('$(MSBuildPathInPackage)')" Text="Something moved around in Microsoft.Build.Runtime, adjust code here accordingly." />

src/Cli/Microsoft.TemplateEngine.Cli/Commands/ParserFactory.cs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,22 @@ namespace Microsoft.TemplateEngine.Cli.Commands
88
{
99
internal static class ParserFactory
1010
{
11-
internal static CommandLineConfiguration CreateParser(Command command, bool disableHelp = false)
11+
internal static readonly ParserConfiguration ParserConfiguration = new()
1212
{
13-
CommandLineConfiguration config = new(command)
14-
//TODO: decide if it's needed to implement it; and implement if needed
15-
//.UseParseDirective()
16-
//.UseSuggestDirective()
17-
{
18-
EnablePosixBundling = false
19-
};
20-
21-
for (int i = 0; i < command.Options.Count; i++)
22-
{
23-
if (command.Options[i] is HelpOption)
24-
{
25-
if (disableHelp)
26-
{
27-
command.Options.RemoveAt(i);
28-
}
13+
EnablePosixBundling = false,
14+
};
2915

30-
return config;
31-
}
32-
}
16+
internal static Command CreateParser(Command command, bool disableHelp = false)
17+
{
18+
// {
19+
// EnablePosixBundling = false
20+
// };
3321

3422
if (!disableHelp)
3523
{
3624
command.Options.Add(new HelpOption());
3725
}
38-
39-
return config;
26+
return command;
4027
}
4128
}
4229
}

src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ internal static IEnumerable<CompletionItem> GetTemplateCompletions(
6060
templateGroup,
6161
template);
6262

63-
CommandLineConfiguration parser = ParserFactory.CreateParser(command);
63+
System.CommandLine.Command parser = ParserFactory.CreateParser(command);
6464

6565
//it is important to pass raw text to get the completion
6666
//completions for args passed as array are not supported
67-
ParseResult parseResult = parser.Parse(context.CommandLineText);
67+
ParseResult parseResult = parser.Parse(context.CommandLineText, ParserFactory.ParserConfiguration);
6868
foreach (CompletionItem completion in parseResult.GetCompletions(context.CursorPosition))
6969
{
7070
////TODO: conditionals tab completion here

0 commit comments

Comments
 (0)