├── .config
└── tsaoptions.json
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .vsts-ci-official.yml
├── .vsts-ci.yml
├── CODE-OF-CONDUCT.md
├── CONTRIBUTING.md
├── Directory.Build.props
├── Directory.Build.rsp
├── Directory.Build.targets
├── Directory.Packages.props
├── LICENSE.md
├── NuGet.config
├── README.md
├── SECURITY.md
├── System.CommandLine.sln
├── System.CommandLine.v3.ncrunchsolution
├── build.cmd
├── build.sh
├── core.slnf
├── docs
├── DragonFruit-overview.md
├── Functional-goals.md
├── History.md
├── Technical-motivations.md
├── Your-first-app-with-System-CommandLine-DragonFruit.md
├── dotnet-suggest.md
├── model-binding.md
└── readme.md
├── eng
├── Build.props
├── DotNetBuild.props
├── Publishing.props
├── Version.Details.xml
├── Versions.props
└── common
│ ├── BuildConfiguration
│ └── build-configuration.json
│ ├── CIBuild.cmd
│ ├── PSScriptAnalyzerSettings.psd1
│ ├── README.md
│ ├── SetupNugetSources.ps1
│ ├── SetupNugetSources.sh
│ ├── build.cmd
│ ├── build.ps1
│ ├── build.sh
│ ├── cibuild.sh
│ ├── core-templates
│ ├── job
│ │ ├── job.yml
│ │ ├── onelocbuild.yml
│ │ ├── publish-build-assets.yml
│ │ ├── source-build.yml
│ │ └── source-index-stage1.yml
│ ├── jobs
│ │ ├── codeql-build.yml
│ │ ├── jobs.yml
│ │ └── source-build.yml
│ ├── post-build
│ │ ├── common-variables.yml
│ │ ├── post-build.yml
│ │ └── setup-maestro-vars.yml
│ ├── steps
│ │ ├── component-governance.yml
│ │ ├── enable-internal-runtimes.yml
│ │ ├── enable-internal-sources.yml
│ │ ├── generate-sbom.yml
│ │ ├── get-delegation-sas.yml
│ │ ├── get-federated-access-token.yml
│ │ ├── publish-build-artifacts.yml
│ │ ├── publish-logs.yml
│ │ ├── publish-pipeline-artifacts.yml
│ │ ├── retain-build.yml
│ │ ├── send-to-helix.yml
│ │ └── source-build.yml
│ └── variables
│ │ └── pool-providers.yml
│ ├── cross
│ ├── arm
│ │ └── tizen
│ │ │ └── tizen.patch
│ ├── arm64
│ │ └── tizen
│ │ │ └── tizen.patch
│ ├── armel
│ │ ├── armel.jessie.patch
│ │ └── tizen
│ │ │ └── tizen.patch
│ ├── build-android-rootfs.sh
│ ├── build-rootfs.sh
│ ├── riscv64
│ │ └── tizen
│ │ │ └── tizen.patch
│ ├── tizen-build-rootfs.sh
│ ├── tizen-fetch.sh
│ ├── toolchain.cmake
│ └── x86
│ │ └── tizen
│ │ └── tizen.patch
│ ├── darc-init.ps1
│ ├── darc-init.sh
│ ├── dotnet-install.cmd
│ ├── dotnet-install.ps1
│ ├── dotnet-install.sh
│ ├── enable-cross-org-publishing.ps1
│ ├── generate-locproject.ps1
│ ├── generate-sbom-prep.ps1
│ ├── generate-sbom-prep.sh
│ ├── helixpublish.proj
│ ├── init-tools-native.cmd
│ ├── init-tools-native.ps1
│ ├── init-tools-native.sh
│ ├── internal-feed-operations.ps1
│ ├── internal-feed-operations.sh
│ ├── internal
│ ├── Directory.Build.props
│ ├── NuGet.config
│ └── Tools.csproj
│ ├── loc
│ └── P22DotNetHtmlLocalization.lss
│ ├── msbuild.ps1
│ ├── msbuild.sh
│ ├── native
│ ├── CommonLibrary.psm1
│ ├── common-library.sh
│ ├── init-compiler.sh
│ ├── init-distro-rid.sh
│ ├── init-os-and-arch.sh
│ ├── install-cmake-test.sh
│ ├── install-cmake.sh
│ └── install-tool.ps1
│ ├── pipeline-logging-functions.ps1
│ ├── pipeline-logging-functions.sh
│ ├── post-build
│ ├── check-channel-consistency.ps1
│ ├── nuget-validation.ps1
│ ├── nuget-verification.ps1
│ ├── publish-using-darc.ps1
│ ├── redact-logs.ps1
│ ├── sourcelink-validation.ps1
│ └── symbols-validation.ps1
│ ├── retain-build.ps1
│ ├── sdk-task.ps1
│ ├── sdl
│ ├── NuGet.config
│ ├── configure-sdl-tool.ps1
│ ├── execute-all-sdl-tools.ps1
│ ├── extract-artifact-archives.ps1
│ ├── extract-artifact-packages.ps1
│ ├── init-sdl.ps1
│ ├── packages.config
│ ├── run-sdl.ps1
│ ├── sdl.ps1
│ └── trim-assets-version.ps1
│ ├── template-guidance.md
│ ├── templates-official
│ ├── job
│ │ ├── job.yml
│ │ ├── onelocbuild.yml
│ │ ├── publish-build-assets.yml
│ │ ├── source-build.yml
│ │ └── source-index-stage1.yml
│ ├── jobs
│ │ ├── codeql-build.yml
│ │ ├── jobs.yml
│ │ └── source-build.yml
│ ├── post-build
│ │ ├── common-variables.yml
│ │ ├── post-build.yml
│ │ └── setup-maestro-vars.yml
│ ├── steps
│ │ ├── component-governance.yml
│ │ ├── enable-internal-runtimes.yml
│ │ ├── enable-internal-sources.yml
│ │ ├── generate-sbom.yml
│ │ ├── get-delegation-sas.yml
│ │ ├── get-federated-access-token.yml
│ │ ├── publish-build-artifacts.yml
│ │ ├── publish-logs.yml
│ │ ├── publish-pipeline-artifacts.yml
│ │ ├── retain-build.yml
│ │ ├── send-to-helix.yml
│ │ └── source-build.yml
│ └── variables
│ │ ├── pool-providers.yml
│ │ └── sdl-variables.yml
│ ├── templates
│ ├── job
│ │ ├── job.yml
│ │ ├── onelocbuild.yml
│ │ ├── publish-build-assets.yml
│ │ ├── source-build.yml
│ │ └── source-index-stage1.yml
│ ├── jobs
│ │ ├── codeql-build.yml
│ │ ├── jobs.yml
│ │ └── source-build.yml
│ ├── post-build
│ │ ├── common-variables.yml
│ │ ├── post-build.yml
│ │ └── setup-maestro-vars.yml
│ ├── steps
│ │ ├── component-governance.yml
│ │ ├── enable-internal-runtimes.yml
│ │ ├── enable-internal-sources.yml
│ │ ├── generate-sbom.yml
│ │ ├── get-delegation-sas.yml
│ │ ├── get-federated-access-token.yml
│ │ ├── publish-build-artifacts.yml
│ │ ├── publish-logs.yml
│ │ ├── publish-pipeline-artifacts.yml
│ │ ├── retain-build.yml
│ │ ├── send-to-helix.yml
│ │ └── source-build.yml
│ └── variables
│ │ └── pool-providers.yml
│ ├── tools.ps1
│ └── tools.sh
├── global.json
├── repack.ps1
├── samples
├── DragonFruit
│ ├── Directory.Build.props
│ ├── Directory.Build.targets
│ ├── DragonFruit.csproj
│ └── Program.cs
├── HostingPlayground
│ ├── Greeter.cs
│ ├── GreeterOptions.cs
│ ├── HostingPlayground.csproj
│ ├── HostingPlaygroundLogEvents.cs
│ ├── IGreeter.cs
│ ├── Program.cs
│ └── appsettings.json
└── RenderingPlayground
│ ├── Colorizer.cs
│ ├── ColorsView.cs
│ ├── Directory.Build.props
│ ├── Directory.Build.targets
│ ├── DirectoryTableView.cs
│ ├── ProcessesView.cs
│ ├── Program.cs
│ ├── RenderingPlayground.csproj
│ └── SampleName.cs
├── sourcebuild.slnf
└── src
├── Common
├── ArgumentBuilder.cs
└── OptionBuilder.cs
├── System.CommandLine.ApiCompatibility.Tests
├── ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt
├── ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt
├── ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt
├── ApiCompatibilityApprovalTests.cs
├── ApiContract.cs
├── Directory.Build.props
├── LocalizationTests.cs
└── System.CommandLine.ApiCompatibility.Tests.csproj
├── System.CommandLine.Benchmarks
├── Categories.cs
├── CommandLine
│ ├── Perf_Parser_CustomScenarios.cs
│ ├── Perf_Parser_Directives_Suggest.cs
│ ├── Perf_Parser_NestedCommands.cs
│ ├── Perf_Parser_Options_Bare.cs
│ ├── Perf_Parser_Options_With_Arguments.cs
│ ├── Perf_Parser_ParseResult.cs
│ ├── Perf_Parser_Simple.cs
│ ├── Perf_Parser_TypoCorrection.cs
│ └── Perf_Suggestions.cs
├── DragonFruit
│ ├── Perf_CommandLine_EntryPoint.cs
│ ├── Perf_CommandLine_Help.cs
│ └── Perf_XmlDocReader.cs
├── Helpers
│ ├── BdnParam.cs
│ ├── NullStreamWriter.cs
│ └── Utils.cs
├── Input
│ └── Sample1.Main.cs
├── Program.cs
├── RecommendedConfig.cs
├── System.CommandLine.Benchmarks.csproj
├── System.CommandLine.Benchmarks.net5.0.v3.ncrunchproject
└── System.CommandLine.Benchmarks.v3.ncrunchproject
├── System.CommandLine.DragonFruit.Tests
├── CommandLineTests.cs
├── ConfigureFromMethodTests.cs
├── EntryPointCreatorTests.cs
├── StringExtensionTests.cs
├── System.CommandLine.DragonFruit.Tests.csproj
├── TestProgram.cs
└── XmlDocReaderTests.cs
├── System.CommandLine.DragonFruit
├── CommandHelpMetadata.cs
├── CommandLine.cs
├── Directory.Build.props
├── EntryPointDiscoverer.cs
├── StringExtensions.cs
├── System.CommandLine.DragonFruit.csproj
├── XmlDocReader.cs
└── targets
│ ├── System.CommandLine.DragonFruit.props
│ └── System.CommandLine.DragonFruit.targets
├── System.CommandLine.Generator.CommandHandler
├── CommandExtensions.cs
└── System.CommandLine.Generator.CommandHandler.csproj
├── System.CommandLine.Generator.Tests
├── Directory.Build.props
├── GeneratedCommandHandlerTests.cs
└── System.CommandLine.Generator.Tests.csproj
├── System.CommandLine.Generator
├── CommandHandlerSourceGenerator.cs
├── Directory.Build.props
├── Invocations
│ ├── ConstructorModelBindingInvocation.cs
│ ├── DelegateInvocation.cs
│ └── ReturnPattern.cs
├── Parameters
│ ├── ArgumentParameter.cs
│ ├── BindingContextParameter.cs
│ ├── ConsoleParameter.cs
│ ├── OptionParameter.cs
│ ├── Parameter.cs
│ ├── ParseResultParameter.cs
│ ├── PropertyParameter.cs
│ └── RawParameter.cs
├── SyntaxReceiver.cs
├── System.CommandLine.Generator.csproj
└── WellKnownTypes.cs
├── System.CommandLine.Hosting.Tests
├── HostingHandlerTest.cs
├── HostingTests.cs
└── System.CommandLine.Hosting.Tests.csproj
├── System.CommandLine.Hosting
├── Directory.Build.props
├── HostingAction.cs
├── HostingExtensions.cs
├── InvocationLifetime.cs
├── InvocationLifetimeOptions.cs
└── System.CommandLine.Hosting.csproj
├── System.CommandLine.NamingConventionBinder.Tests
├── BindingTestCase.cs
├── BindingTestSet.cs
├── HandlerDescriptorTests.cs
├── ModelBinderTests.cs
├── ModelBindingCommandHandlerTests.BindingByName.cs
├── ModelBindingCommandHandlerTests.cs
├── ModelDescriptorTests.cs
├── ParameterBindingTests.cs
├── ParameterDescriptorTests.cs
├── PropertyDescriptorTests.cs
└── System.CommandLine.NamingConventionBinder.Tests.csproj
├── System.CommandLine.NamingConventionBinder
├── BindingContext.cs
├── BindingContextExtensions.cs
├── BindingHandler.cs
├── BoundValue.cs
├── CommandHandler.cs
├── CommandResultExtensions.cs
├── ConstructorDescriptor.cs
├── DelegateHandlerDescriptor.cs
├── DelegateValueSource.cs
├── Directory.Build.props
├── ExpressionExtensions.cs
├── HandlerDescriptor.cs
├── IMethodDescriptor.cs
├── IValueDescriptor.cs
├── IValueSource.cs
├── MethodInfoHandlerDescriptor.cs
├── MissingValueSource.cs
├── ModelBinder.cs
├── ModelBinderCollection.cs
├── ModelBinder{T}.cs
├── ModelBindingCommandHandler.cs
├── ModelDescriptor.cs
├── ParameterDescriptor.cs
├── ParseResultMatchingValueSource.cs
├── PropertyDescriptor.cs
├── ServiceProvider.cs
├── ServiceProviderValueSource.cs
├── SpecificSymbolValueSource.cs
├── System.CommandLine.NamingConventionBinder.csproj
├── TypeExtensions.cs
└── ValueDescriptorDefaultValueSource.cs
├── System.CommandLine.Rendering.Tests
├── AnsiControlCodeTests.cs
├── AnsiTests.cs
├── ConsoleFormatInfoTests.cs
├── ConsoleRendererTests.cs
├── ContainerSpanTests.cs
├── ControlSpanTests.cs
├── Example_TOP.cs
├── OutputFormattingTests.cs
├── RegionTests.cs
├── RenderingTestCase.cs
├── SizeTests.cs
├── System.CommandLine.Rendering.Tests.csproj
├── SystemConsoleTerminalTests.cs
├── TableRenderingTests.cs
├── TerminalModeTests.cs
├── TerminalTests.cs
├── TestTerminalTests.cs
├── TextSpanFormatterTests.cs
├── TextSpanTests.cs
├── TextSpanVisitorTests.cs
├── TextStyleRenderingTests.cs
├── ViewRenderingTests.cs
├── ViewWrappingTests.cs
├── Views
│ ├── ColumnDefinitionTests.cs
│ ├── ContentViewTests.cs
│ ├── ContentView{T}Tests.cs
│ ├── GridViewTests.cs
│ ├── LayoutViewTests.cs
│ ├── RowDefinitionTests.cs
│ ├── ScreenViewTests.cs
│ └── StackLayoutViewTests.cs
├── WordWrappingTests.cs
└── WrappingExtensionsTests.cs
├── System.CommandLine.Rendering
├── Ansi.cs
├── AnsiControlCode.cs
├── AnsiRenderingSpanVisitor.cs
├── BackgroundColorSpan.cs
├── ColorSpan.cs
├── ConsoleExtensions.cs
├── ConsoleFormatInfo.cs
├── ConsoleRenderer.cs
├── ContainerSpan.cs
├── ContentRenderingSpanVisitor.cs
├── ContentSpan.cs
├── ControlSpan.cs
├── CursorControlSpan.cs
├── Directory.Build.props
├── EntireTerminalRegion.cs
├── FileRenderingSpanVisitor.cs
├── ForegroundColorSpan.cs
├── IConsole.cs
├── IO
│ ├── IStandardError.cs
│ ├── IStandardIn.cs
│ ├── IStandardOut.cs
│ ├── IStandardStreamWriter.cs
│ ├── StandardStreamWriter.cs
│ ├── SystemConsole.cs
│ └── TestConsole.cs
├── IRenderable.cs
├── ITerminal.cs
├── Interop.Windows.cs
├── NonAnsiRenderingSpanVisitor.cs
├── OutputMode.cs
├── RecordingWriter.cs
├── Region.cs
├── RgbColor.cs
├── ScrollingTerminalRegion.cs
├── Size.cs
├── SpanMeasuringVisitor.cs
├── StringExtensions.cs
├── StyleSpan.cs
├── System.CommandLine.Rendering.csproj
├── SystemConsoleTerminal.cs
├── Terminal.cs
├── TerminalBase.cs
├── TestTerminal.cs
├── TextSpan.cs
├── TextSpanFormatter.cs
├── TextSpanVisitor.cs
├── Views
│ ├── ColumnDefinition.cs
│ ├── ContentView.cs
│ ├── ContentView{T}.cs
│ ├── GridView.cs
│ ├── ItemsView.cs
│ ├── LayoutView.cs
│ ├── Orientation.cs
│ ├── RowDefinition.cs
│ ├── ScreenView.cs
│ ├── SizeMode.cs
│ ├── StackLayoutView.cs
│ ├── TableView.cs
│ ├── TableViewColumn.cs
│ └── View.cs
├── VirtualTerminal.cs
├── VirtualTerminalMode.cs
└── WrappingExtensions.cs
├── System.CommandLine.Suggest.Tests
├── DotnetSuggestEndToEndTests.cs
├── EndToEndTestApp
│ ├── EndToEndTestApp.csproj
│ └── Program.cs
├── FileEnumeratorTests.cs
├── FileSuggestionProviderTests.cs
├── GlobalToolsSuggestionRegistrationTests.cs
├── SuggestionDispatcherTests.cs
├── SuggestionRegistrationTest.cs
├── SuggestionShellScriptHandlerTest.cs
├── TestSuggestionRegistration.cs
├── TestSuggestionRegistrationTests.cs
└── dotnet-suggest.Tests.csproj
├── System.CommandLine.Suggest
├── CombineSuggestionRegistration.cs
├── Directory.Build.props
├── DotnetMuxer.cs
├── DotnetProfileDirectory.cs
├── FileEnumerator.cs
├── FileSuggestionRegistration.cs
├── GlobalToolsSuggestionRegistration.cs
├── ISuggestionRegistration.cs
├── ISuggestionStore.cs
├── PathExtensions.cs
├── Program.cs
├── RegistrationPair.cs
├── ShellType.cs
├── StringExtensions.cs
├── SuggestionDispatcher.cs
├── SuggestionShellScriptException.cs
├── SuggestionShellScriptHandler.cs
├── SuggestionStore.cs
├── build-and-install.ps1
├── dotnet-suggest-shim.bash
├── dotnet-suggest-shim.ps1
├── dotnet-suggest-shim.zsh
└── dotnet-suggest.csproj
├── System.CommandLine.Tests
├── ArgumentTests.cs
├── Binding
│ ├── TestModels.cs
│ └── TypeConversionTests.cs
├── CommandLineConfigurationTests.cs
├── CommandTests.cs
├── CompilationTests.cs
├── CompletionContextTests.cs
├── CompletionTests.cs
├── CustomParsingTests.cs
├── DirectiveTests.cs
├── Directory.Build.props
├── EnvironmentVariableDirectiveTests.cs
├── GetValueByNameParserTests.cs
├── GlobalOptionTests.cs
├── Help
│ ├── ApprovalTests.Config.cs
│ ├── Approvals
│ │ └── HelpBuilderTests.Help_layout_has_not_changed.approved.txt
│ ├── CustomHelpAction.cs
│ ├── HelpBuilderExtensions.cs
│ ├── HelpBuilderTests.Approval.cs
│ ├── HelpBuilderTests.Customization.cs
│ └── HelpBuilderTests.cs
├── HelpOptionTests.cs
├── Invocation
│ ├── CancelOnProcessTerminationTests.cs
│ ├── InvocationTests.cs
│ └── TypoCorrectionTests.cs
├── OptionTests.MultipleArgumentsPerToken.cs
├── OptionTests.cs
├── ParseDiagramTests.cs
├── ParseDirectiveTests.cs
├── ParseErrorReportingTests.cs
├── ParseResultTests.cs
├── ParserTests.DoubleDash.cs
├── ParserTests.MultipleArguments.cs
├── ParserTests.MultiplePositions.cs
├── ParserTests.RootCommandAndArg0.cs
├── ParserTests.SetupErrors.cs
├── ParserTests.cs
├── Parsing
│ └── CommandLineStringSplitterTests.cs
├── ParsingValidationTests.cs
├── ResponseFileTests.cs
├── RootCommandTests.cs
├── SplitCommandLineTests.cs
├── SuggestDirectiveTests.cs
├── System.CommandLine.Tests.csproj
├── TestApps
│ ├── NativeAOT
│ │ ├── NativeAOT.csproj
│ │ └── Program.cs
│ └── Trimming
│ │ ├── Program.cs
│ │ └── Trimming.csproj
├── TestCliActions.cs
├── TokenReplacementTests.cs
├── UseExceptionHandlerTests.cs
├── Utility
│ ├── AssertionExtensions.cs
│ ├── LinuxOnlyTheory.cs
│ ├── NonWindowsOnlyFactAttribute.cs
│ ├── ParseResultExtensions.cs
│ ├── Process.cs
│ ├── ReleaseBuildOnlyFactAttribute.cs
│ ├── ReleaseBuildOnlyTheoryAttribute.cs
│ ├── RemoteExecution.cs
│ ├── RemoteExecutor.cs
│ └── WindowsOnlyFactAttribute.cs
└── VersionOptionTests.cs
├── System.CommandLine
├── AliasSet.cs
├── Argument.cs
├── ArgumentArity.cs
├── ArgumentValidation.cs
├── Argument{T}.cs
├── Binding
│ ├── ArgumentConversionResult.cs
│ ├── ArgumentConversionResultType.cs
│ ├── ArgumentConverter.DefaultValues.cs
│ ├── ArgumentConverter.StringConverters.cs
│ ├── ArgumentConverter.cs
│ ├── TryConvertArgument.cs
│ └── TypeExtensions.cs
├── ChildSymbolList{T}.cs
├── Command.cs
├── CommandLineConfiguration.cs
├── CommandLineConfigurationException.cs
├── CompletionSourceExtensions.cs
├── Completions
│ ├── CompletionAction.cs
│ ├── CompletionContext.cs
│ ├── CompletionItem.cs
│ ├── SuggestDirective.cs
│ └── TextCompletionContext.cs
├── ConsoleHelpers.cs
├── Directive.cs
├── Directory.Build.props
├── EnumerableExtensions.cs
├── EnvironmentVariablesDirective.cs
├── Help
│ ├── HelpAction.cs
│ ├── HelpBuilder.Default.cs
│ ├── HelpBuilder.cs
│ ├── HelpBuilderExtensions.cs
│ ├── HelpContext.cs
│ ├── HelpOption.cs
│ └── TwoColumnHelpRow.cs
├── Invocation
│ ├── AnonymousAsynchronousCommandLineAction.cs
│ ├── AnonymousSynchronousCommandLineAction.cs
│ ├── AsynchronousCommandLineAction.cs
│ ├── CommandLineAction.cs
│ ├── InvocationPipeline.cs
│ ├── ParseErrorAction.cs
│ ├── ProcessTerminationHandler.cs
│ └── SynchronousCommandLineAction.cs
├── LocalizationResources.cs
├── Option.cs
├── OptionValidation.cs
├── Option{T}.cs
├── ParseDiagramDirective.cs
├── ParseResult.cs
├── Parsing
│ ├── ArgumentResult.cs
│ ├── CommandLineParser.cs
│ ├── CommandResult.cs
│ ├── DirectiveResult.cs
│ ├── OptionResult.cs
│ ├── ParseDiagramAction.cs
│ ├── ParseError.cs
│ ├── ParseOperation.cs
│ ├── StringExtensions.cs
│ ├── SymbolResult.cs
│ ├── SymbolResultExtensions.cs
│ ├── SymbolResultTree.cs
│ ├── Token.cs
│ ├── TokenType.cs
│ └── TryReplaceToken.cs
├── Properties
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ └── xlf
│ │ ├── Resources.cs.xlf
│ │ ├── Resources.de.xlf
│ │ ├── Resources.es.xlf
│ │ ├── Resources.fr.xlf
│ │ ├── Resources.it.xlf
│ │ ├── Resources.ja.xlf
│ │ ├── Resources.ko.xlf
│ │ ├── Resources.pl.xlf
│ │ ├── Resources.pt-BR.xlf
│ │ ├── Resources.ru.xlf
│ │ ├── Resources.tr.xlf
│ │ ├── Resources.zh-Hans.xlf
│ │ └── Resources.zh-Hant.xlf
├── RootCommand.cs
├── Symbol.cs
├── SymbolNode.cs
├── System.CommandLine.Config.cs
├── System.CommandLine.csproj
├── System.Diagnostics.CodeAnalysis
│ ├── DynamicallyAccessedMemberTypes.cs
│ ├── DynamicallyAccessedMembersAttribute.cs
│ └── UnconditionalSuppressMessageAttribute.cs
├── System.Runtime.CompilerServices
│ └── IsExternalInit.cs
└── VersionOption.cs
└── System.Diagnostics.CodeAnalysis.cs
/.config/tsaoptions.json:
--------------------------------------------------------------------------------
1 | {
2 | "instanceUrl": "https://devdiv.visualstudio.com/",
3 | "template": "TFSDEVDIV",
4 | "projectName": "DEVDIV",
5 | "areaPath": "DevDiv\\NET Libraries",
6 | "iterationPath": "DevDiv",
7 | "notificationAliases": [ "system-commandline@microsoft.com" ],
8 | "repositoryName":"command-line-api",
9 | "codebaseName": "command-line-api",
10 | "serviceTreeId": "7a9b52f6-7805-416c-9390-343168c0cdb3"
11 | }
12 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 |
2 | [*.{c,c++,cc,cp,cpp,cu,cuh,cxx,h,hh,hpp,hxx,inc,inl,ino,ipp,mpp,proto,tpp}]
3 | indent_style=tab
4 | indent_size=tab
5 | tab_width=4
6 |
7 | [*.{asax,ascx,aspx,cs,cshtml,css,htm,html,js,jsx,master,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}]
8 | indent_style=space
9 | indent_size=4
10 | tab_width=4
11 |
12 | [*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
13 | indent_style=space
14 | indent_size=2
15 | tab_width=2
16 |
17 | [*]
18 |
19 | # Microsoft .NET properties
20 | csharp_new_line_before_members_in_object_initializers=false
21 | csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
22 | csharp_style_var_elsewhere=true:hint
23 | csharp_style_var_for_built_in_types=true:hint
24 | csharp_style_var_when_type_is_apparent=true:hint
25 | dotnet_style_predefined_type_for_locals_parameters_members=true:hint
26 | dotnet_style_predefined_type_for_member_access=true:hint
27 | dotnet_style_qualification_for_event=false:warning
28 | dotnet_style_qualification_for_field=false:warning
29 | dotnet_style_qualification_for_method=false:warning
30 | dotnet_style_qualification_for_property=false:warning
31 | dotnet_style_require_accessibility_modifiers=for_non_interface_members:hint
32 |
--------------------------------------------------------------------------------
/CODE-OF-CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | This project has adopted the code of conduct defined by the Contributor Covenant
4 | to clarify expected behavior in our community.
5 |
6 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
7 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ============
3 |
4 | Please read [.NET Guidelines](https://github.com/dotnet/runtime/blob/master/CONTRIBUTING.md) for more general information about coding styles, source structure, making pull requests, and more.
5 |
6 | ## Developer guide
7 |
8 | This project can be developed on any platform. To get started, follow instructions for your OS.
9 |
10 | ### Prerequisites
11 |
12 | This project depends on .NET 7. Before working on the project, check that the [.NET SDK](https://dotnet.microsoft.com/en-us/download) is installed.
13 |
14 | ### Visual Studio
15 |
16 | This project supports [Visual Studio 2022](https://visualstudio.com). Any version, including the free Community Edition, should be sufficient.
17 |
18 | This project also supports using
19 | [Visual Studio Code](https://code.visualstudio.com). Install the [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit).
20 |
21 | ### Command line scripts
22 |
23 | This project can be built on the command line using the `build.cmd`/`build.sh` scripts.
24 |
25 | Run `.\build.cmd -help` or `./build.sh --help` to see more options.
26 |
27 | ### Compile
28 |
29 | Windows:
30 |
31 | > .\build.cmd
32 |
33 | macOS/Linux
34 |
35 | $ ./build.sh
36 |
37 | ### Running tests
38 |
39 | To build **and** run tests:
40 |
41 | Windows:
42 |
43 | > .\build.cmd -test
44 |
45 | macOS/Linux:
46 |
47 | $ ./build.sh --test
48 |
49 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | $(NoWarn);NU5125;CS0618
9 | MIT
10 | 13.0
11 | https://github.com/dotnet/command-line-api
12 |
13 |
14 |
15 | $(NetCurrent)
16 | net8.0
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Directory.Build.rsp:
--------------------------------------------------------------------------------
1 | # This file intentionally left blank to avoid accidental import during build.
2 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | $(DefaultExcludesInProjectFolder);TestResults\**
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright © .NET Foundation and Contributors
4 |
5 | All rights reserved.
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | The .NET Core and ASP.NET Core support policy, including supported versions can be found at the [.NET Core Support Policy Page](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
6 |
7 | ## Reporting a Vulnerability
8 |
9 | Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC), either by emailing secure@microsoft.com or via the portal at https://msrc.microsoft.com.
10 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your
11 | original message. Further information, including the MSRC PGP key, can be found in the [MSRC Report an Issue FAQ](https://www.microsoft.com/en-us/msrc/faqs-report-an-issue).
12 |
13 | Reports via MSRC may qualify for the .NET Core Bug Bounty. Details of the .NET Core Bug Bounty including terms and conditions are at [https://aka.ms/corebounty](https://aka.ms/corebounty).
14 |
15 | Please do not open issues for anything you think might have a security implication.
--------------------------------------------------------------------------------
/System.CommandLine.v3.ncrunchsolution:
--------------------------------------------------------------------------------
1 |
2 |
3 | True
4 |
5 | TargetFrameworks = net8.0
6 | TargetFramework = net8.0
7 |
8 | False
9 | True
10 | True
11 |
12 |
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -NoLogo -NoProfile -ExecutionPolicy ByPass %~dp0eng\common\build.ps1 -build -restore %*
3 | exit /b %ErrorLevel%
4 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 |
5 | # resolve $SOURCE until the file is no longer a symlink
6 | while [[ -h $source ]]; do
7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8 | source="$(readlink "$source")"
9 |
10 | # if $source was a relative symlink, we need to resolve it relative to the path where the
11 | # symlink file was located
12 | [[ $source != /* ]] && source="$scriptroot/$source"
13 | done
14 |
15 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
16 | "$scriptroot/eng/common/build.sh" --build --restore $@
17 |
--------------------------------------------------------------------------------
/core.slnf:
--------------------------------------------------------------------------------
1 | {
2 | "solution": {
3 | "path": "System.CommandLine.sln",
4 | "projects": [
5 | "src\\System.CommandLine.ApiCompatibility.Tests\\System.CommandLine.ApiCompatibility.Tests.csproj",
6 | "src\\System.CommandLine.DragonFruit\\System.CommandLine.DragonFruit.csproj",
7 | "src\\System.CommandLine.NamingConventionBinder.Tests\\System.CommandLine.NamingConventionBinder.Tests.csproj",
8 | "src\\System.CommandLine.NamingConventionBinder\\System.CommandLine.NamingConventionBinder.csproj",
9 | "src\\System.CommandLine.Tests\\System.CommandLine.Tests.csproj",
10 | "src\\System.CommandLine\\System.CommandLine.csproj"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/docs/dotnet-suggest.md:
--------------------------------------------------------------------------------
1 | # dotnet-suggest
2 |
3 | Command line apps built using `System.CommandLine` have built-in support for tab completion.
4 |
5 | 
6 |
7 | On the machine where you'd like to enable completion, you'll need to do two things.
8 |
9 | 1. Install the `dotnet-suggest` global tool:
10 |
11 | ```sh
12 | dotnet tool install -g dotnet-suggest
13 | ```
14 |
15 | 2. Install the completion script.
16 |
17 | ### bash
18 | ```sh
19 | dotnet-suggest script bash >~/.dotnet-suggest-shim.bash
20 | echo '. ~/.dotnet-suggest-shim.bash' >>~/.bashrc
21 | ```
22 |
23 | ### zsh
24 | ```sh
25 | dotnet-suggest script zsh >~/.dotnet-suggest-shim.zsh
26 | echo '. ~/.dotnet-suggest-shim.zsh' >>~/.zshrc
27 | ```
28 |
29 | ### PowerShell
30 |
31 | Add the contents of [dotnet-suggest-shim.ps1](https://github.com/dotnet/command-line-api/blob/master/src/System.CommandLine.Suggest/dotnet-suggest-shim.ps1) to your PowerShell profile. You can find the expected path to your PowerShell profile by running the following in your console:
32 |
33 | ```console
34 | > echo $profile
35 | ```
36 |
37 | (For other shells, please [look for](https://github.com/dotnet/command-line-api/issues?q=is%3Aissue+is%3Aopen+label%3A%22shell+suggestion%22) or open an [issue](https://github.com/dotnet/command-line-api/issues).)
38 |
--------------------------------------------------------------------------------
/docs/readme.md:
--------------------------------------------------------------------------------
1 | The System.CommandLine documentation can now be found at [Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/standard/commandline/).
2 |
--------------------------------------------------------------------------------
/eng/Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/eng/DotNetBuild.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | command-line-api
7 | true
8 | $(DotNetBuildFromVMR)
9 | false
10 | false
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/eng/Publishing.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/eng/Version.Details.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | https://github.com/dotnet/arcade
9 | 086a1771875b63404b4a710d27250fe384dc2810
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/eng/Versions.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 0.1.0
6 | true
7 |
8 |
9 |
10 |
11 | false
12 |
13 |
14 | 2.0.0
15 | beta5
16 | false
17 |
18 |
19 | 0.4.0
20 | alpha
21 | false
22 |
23 |
24 |
--------------------------------------------------------------------------------
/eng/common/BuildConfiguration/build-configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "RetryCountLimit": 1,
3 | "RetryByAnyError": false
4 | }
5 |
--------------------------------------------------------------------------------
/eng/common/CIBuild.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
--------------------------------------------------------------------------------
/eng/common/PSScriptAnalyzerSettings.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | IncludeRules=@('PSAvoidUsingCmdletAliases',
3 | 'PSAvoidUsingWMICmdlet',
4 | 'PSAvoidUsingPositionalParameters',
5 | 'PSAvoidUsingInvokeExpression',
6 | 'PSUseDeclaredVarsMoreThanAssignments',
7 | 'PSUseCmdletCorrectly',
8 | 'PSStandardDSCFunctionsInResource',
9 | 'PSUseIdenticalMandatoryParametersForDSC',
10 | 'PSUseIdenticalParametersForDSC')
11 | }
--------------------------------------------------------------------------------
/eng/common/README.md:
--------------------------------------------------------------------------------
1 | # Don't touch this folder
2 |
3 | uuuuuuuuuuuuuuuuuuuu
4 | u" uuuuuuuuuuuuuuuuuu "u
5 | u" u$$$$$$$$$$$$$$$$$$$$u "u
6 | u" u$$$$$$$$$$$$$$$$$$$$$$$$u "u
7 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
8 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
9 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
10 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
11 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
12 | $ $$$" ... "$... ...$" ... "$$$ ... "$$$ $
13 | $ $$$u `"$$$$$$$ $$$ $$$$$ $$ $$$ $$$ $
14 | $ $$$$$$uu "$$$$ $$$ $$$$$ $$ """ u$$$ $
15 | $ $$$""$$$ $$$$ $$$u "$$$" u$$ $$$$$$$$ $
16 | $ $$$$....,$$$$$..$$$$$....,$$$$..$$$$$$$$ $
17 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
18 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
19 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
20 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
21 | "u "$$$$$$$$$$$$$$$$$$$$$$$$" u"
22 | "u "$$$$$$$$$$$$$$$$$$$$" u"
23 | "u """""""""""""""""" u"
24 | """"""""""""""""""""
25 |
26 | !!! Changes made in this directory are subject to being overwritten by automation !!!
27 |
28 | The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first.
29 |
--------------------------------------------------------------------------------
/eng/common/build.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0build.ps1""" %*"
3 | exit /b %ErrorLevel%
4 |
--------------------------------------------------------------------------------
/eng/common/cibuild.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 |
5 | # resolve $SOURCE until the file is no longer a symlink
6 | while [[ -h $source ]]; do
7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8 | source="$(readlink "$source")"
9 |
10 | # if $source was a relative symlink, we need to resolve it relative to the path where
11 | # the symlink file was located
12 | [[ $source != /* ]] && source="$scriptroot/$source"
13 | done
14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
15 |
16 | . "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@
--------------------------------------------------------------------------------
/eng/common/core-templates/jobs/codeql-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md
3 | continueOnError: false
4 | # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job
5 | jobs: []
6 | # Optional: if specified, restore and use this version of Guardian instead of the default.
7 | overrideGuardianVersion: ''
8 | is1ESPipeline: ''
9 |
10 | jobs:
11 | - template: /eng/common/core-templates/jobs/jobs.yml
12 | parameters:
13 | is1ESPipeline: ${{ parameters.is1ESPipeline }}
14 | enableMicrobuild: false
15 | enablePublishBuildArtifacts: false
16 | enablePublishTestResults: false
17 | enablePublishBuildAssets: false
18 | enablePublishUsingPipelines: false
19 | enableTelemetry: true
20 |
21 | variables:
22 | - group: Publish-Build-Assets
23 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
24 | # sync with the packages.config file.
25 | - name: DefaultGuardianVersion
26 | value: 0.109.0
27 | - name: GuardianPackagesConfigFile
28 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
29 | - name: GuardianVersion
30 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }}
31 |
32 | jobs: ${{ parameters.jobs }}
33 |
34 |
--------------------------------------------------------------------------------
/eng/common/core-templates/post-build/common-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - group: Publish-Build-Assets
3 |
4 | # Whether the build is internal or not
5 | - name: IsInternalBuild
6 | value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }}
7 |
8 | # Default Maestro++ API Endpoint and API Version
9 | - name: MaestroApiEndPoint
10 | value: "https://maestro.dot.net"
11 | - name: MaestroApiVersion
12 | value: "2020-02-20"
13 |
14 | - name: SourceLinkCLIVersion
15 | value: 3.0.0
16 | - name: SymbolToolVersion
17 | value: 1.0.1
18 | - name: BinlogToolVersion
19 | value: 1.0.11
20 |
21 | - name: runCodesignValidationInjection
22 | value: false
23 |
--------------------------------------------------------------------------------
/eng/common/core-templates/steps/component-governance.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | disableComponentGovernance: false
3 | componentGovernanceIgnoreDirectories: ''
4 | is1ESPipeline: false
5 | displayName: 'Component Detection'
6 |
7 | steps:
8 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}:
9 | - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
10 | displayName: Set skipComponentGovernanceDetection variable
11 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}:
12 | - task: ComponentGovernanceComponentDetection@0
13 | continueOnError: true
14 | displayName: ${{ parameters.displayName }}
15 | inputs:
16 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
17 |
--------------------------------------------------------------------------------
/eng/common/core-templates/steps/enable-internal-runtimes.yml:
--------------------------------------------------------------------------------
1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64'
2 | # variable with the base64-encoded SAS token, by default
3 |
4 | parameters:
5 | - name: federatedServiceConnection
6 | type: string
7 | default: 'dotnetbuilds-internal-read'
8 | - name: outputVariableName
9 | type: string
10 | default: 'dotnetbuilds-internal-container-read-token-base64'
11 | - name: expiryInHours
12 | type: number
13 | default: 1
14 | - name: base64Encode
15 | type: boolean
16 | default: true
17 | - name: is1ESPipeline
18 | type: boolean
19 | default: false
20 |
21 | steps:
22 | - ${{ if ne(variables['System.TeamProject'], 'public') }}:
23 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml
24 | parameters:
25 | federatedServiceConnection: ${{ parameters.federatedServiceConnection }}
26 | outputVariableName: ${{ parameters.outputVariableName }}
27 | expiryInHours: ${{ parameters.expiryInHours }}
28 | base64Encode: ${{ parameters.base64Encode }}
29 | storageAccount: dotnetbuilds
30 | container: internal
31 | permissions: rl
32 | is1ESPipeline: ${{ parameters.is1ESPipeline }}
--------------------------------------------------------------------------------
/eng/common/core-templates/steps/publish-build-artifacts.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: is1ESPipeline
3 | type: boolean
4 | default: false
5 | - name: args
6 | type: object
7 | default: {}
8 | steps:
9 | - ${{ if ne(parameters.is1ESPipeline, true) }}:
10 | - template: /eng/common/templates/steps/publish-build-artifacts.yml
11 | parameters:
12 | is1ESPipeline: ${{ parameters.is1ESPipeline }}
13 | ${{ each parameter in parameters.args }}:
14 | ${{ parameter.key }}: ${{ parameter.value }}
15 | - ${{ else }}:
16 | - template: /eng/common/templates-official/steps/publish-build-artifacts.yml
17 | parameters:
18 | is1ESPipeline: ${{ parameters.is1ESPipeline }}
19 | ${{ each parameter in parameters.args }}:
20 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/core-templates/steps/publish-pipeline-artifacts.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: is1ESPipeline
3 | type: boolean
4 | default: false
5 |
6 | - name: args
7 | type: object
8 | default: {}
9 |
10 | steps:
11 | - ${{ if ne(parameters.is1ESPipeline, true) }}:
12 | - template: /eng/common/templates/steps/publish-pipeline-artifacts.yml
13 | parameters:
14 | ${{ each parameter in parameters }}:
15 | ${{ parameter.key }}: ${{ parameter.value }}
16 | - ${{ else }}:
17 | - template: /eng/common/templates-official/steps/publish-pipeline-artifacts.yml
18 | parameters:
19 | ${{ each parameter in parameters }}:
20 | ${{ parameter.key }}: ${{ parameter.value }}
21 |
--------------------------------------------------------------------------------
/eng/common/core-templates/steps/retain-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # Optional azure devops PAT with build execute permissions for the build's organization,
3 | # only needed if the build that should be retained ran on a different organization than
4 | # the pipeline where this template is executing from
5 | Token: ''
6 | # Optional BuildId to retain, defaults to the current running build
7 | BuildId: ''
8 | # Azure devops Organization URI for the build in the https://dev.azure.com/ format.
9 | # Defaults to the organization the current pipeline is running on
10 | AzdoOrgUri: '$(System.CollectionUri)'
11 | # Azure devops project for the build. Defaults to the project the current pipeline is running on
12 | AzdoProject: '$(System.TeamProject)'
13 |
14 | steps:
15 | - task: powershell@2
16 | inputs:
17 | targetType: 'filePath'
18 | filePath: eng/common/retain-build.ps1
19 | pwsh: true
20 | arguments: >
21 | -AzdoOrgUri: ${{parameters.AzdoOrgUri}}
22 | -AzdoProject ${{parameters.AzdoProject}}
23 | -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }}
24 | -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}}
25 | displayName: Enable permanent build retention
26 | env:
27 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
28 | BUILD_ID: $(Build.BuildId)
--------------------------------------------------------------------------------
/eng/common/core-templates/variables/pool-providers.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | is1ESPipeline: false
3 |
4 | variables:
5 | - ${{ if eq(parameters.is1ESPipeline, 'true') }}:
6 | - template: /eng/common/templates-official/variables/pool-providers.yml
7 | - ${{ else }}:
8 | - template: /eng/common/templates/variables/pool-providers.yml
--------------------------------------------------------------------------------
/eng/common/cross/arm/tizen/tizen.patch:
--------------------------------------------------------------------------------
1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900
3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900
4 | @@ -2,4 +2,4 @@
5 | Use the shared library, but some functions are only in
6 | the static library, so try that secondarily. */
7 | OUTPUT_FORMAT(elf32-littlearm)
8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-armhf.so.3 ) )
9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-armhf.so.3 ) )
10 |
--------------------------------------------------------------------------------
/eng/common/cross/arm64/tizen/tizen.patch:
--------------------------------------------------------------------------------
1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
2 | --- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900
3 | +++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900
4 | @@ -2,4 +2,4 @@
5 | Use the shared library, but some functions are only in
6 | the static library, so try that secondarily. */
7 | OUTPUT_FORMAT(elf64-littleaarch64)
8 | -GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-aarch64.so.1 ) )
9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-aarch64.so.1 ) )
10 |
--------------------------------------------------------------------------------
/eng/common/cross/armel/armel.jessie.patch:
--------------------------------------------------------------------------------
1 | diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h
2 | --- a/usr/include/urcu/uatomic/generic.h 2014-10-22 15:00:58.000000000 -0700
3 | +++ b/usr/include/urcu/uatomic/generic.h 2020-10-30 21:38:28.550000000 -0700
4 | @@ -69,10 +69,10 @@
5 | #endif
6 | #ifdef UATOMIC_HAS_ATOMIC_SHORT
7 | case 2:
8 | - return __sync_val_compare_and_swap_2(addr, old, _new);
9 | + return __sync_val_compare_and_swap_2((uint16_t*) addr, old, _new);
10 | #endif
11 | case 4:
12 | - return __sync_val_compare_and_swap_4(addr, old, _new);
13 | + return __sync_val_compare_and_swap_4((uint32_t*) addr, old, _new);
14 | #if (CAA_BITS_PER_LONG == 64)
15 | case 8:
16 | return __sync_val_compare_and_swap_8(addr, old, _new);
17 | @@ -109,7 +109,7 @@
18 | return;
19 | #endif
20 | case 4:
21 | - __sync_and_and_fetch_4(addr, val);
22 | + __sync_and_and_fetch_4((uint32_t*) addr, val);
23 | return;
24 | #if (CAA_BITS_PER_LONG == 64)
25 | case 8:
26 | @@ -148,7 +148,7 @@
27 | return;
28 | #endif
29 | case 4:
30 | - __sync_or_and_fetch_4(addr, val);
31 | + __sync_or_and_fetch_4((uint32_t*) addr, val);
32 | return;
33 | #if (CAA_BITS_PER_LONG == 64)
34 | case 8:
35 | @@ -187,7 +187,7 @@
36 | return __sync_add_and_fetch_2(addr, val);
37 | #endif
38 | case 4:
39 | - return __sync_add_and_fetch_4(addr, val);
40 | + return __sync_add_and_fetch_4((uint32_t*) addr, val);
41 | #if (CAA_BITS_PER_LONG == 64)
42 | case 8:
43 | return __sync_add_and_fetch_8(addr, val);
44 |
--------------------------------------------------------------------------------
/eng/common/cross/armel/tizen/tizen.patch:
--------------------------------------------------------------------------------
1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900
3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900
4 | @@ -2,4 +2,4 @@
5 | Use the shared library, but some functions are only in
6 | the static library, so try that secondarily. */
7 | OUTPUT_FORMAT(elf32-littlearm)
8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.3 ) )
9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.3 ) )
10 |
--------------------------------------------------------------------------------
/eng/common/cross/riscv64/tizen/tizen.patch:
--------------------------------------------------------------------------------
1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
2 | --- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900
3 | +++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900
4 | @@ -2,4 +2,4 @@
5 | Use the shared library, but some functions are only in
6 | the static library, so try that secondarily. */
7 | OUTPUT_FORMAT(elf64-littleriscv)
8 | -GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-riscv64-lp64d.so.1 ) )
9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-riscv64-lp64d.so.1 ) )
10 |
--------------------------------------------------------------------------------
/eng/common/cross/x86/tizen/tizen.patch:
--------------------------------------------------------------------------------
1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900
3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900
4 | @@ -2,4 +2,4 @@
5 | Use the shared library, but some functions are only in
6 | the static library, so try that secondarily. */
7 | OUTPUT_FORMAT(elf32-i386)
8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) )
9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.2 ) )
10 |
--------------------------------------------------------------------------------
/eng/common/dotnet-install.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0dotnet-install.ps1""" %*"
--------------------------------------------------------------------------------
/eng/common/dotnet-install.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(PositionalBinding=$false)]
2 | Param(
3 | [string] $verbosity = 'minimal',
4 | [string] $architecture = '',
5 | [string] $version = 'Latest',
6 | [string] $runtime = 'dotnet',
7 | [string] $RuntimeSourceFeed = '',
8 | [string] $RuntimeSourceFeedKey = ''
9 | )
10 |
11 | . $PSScriptRoot\tools.ps1
12 |
13 | $dotnetRoot = Join-Path $RepoRoot '.dotnet'
14 |
15 | $installdir = $dotnetRoot
16 | try {
17 | if ($architecture -and $architecture.Trim() -eq 'x86') {
18 | $installdir = Join-Path $installdir 'x86'
19 | }
20 | InstallDotNet $installdir $version $architecture $runtime $true -RuntimeSourceFeed $RuntimeSourceFeed -RuntimeSourceFeedKey $RuntimeSourceFeedKey
21 | }
22 | catch {
23 | Write-Host $_.ScriptStackTrace
24 | Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_
25 | ExitWithExitCode 1
26 | }
27 |
28 | ExitWithExitCode 0
29 |
--------------------------------------------------------------------------------
/eng/common/enable-cross-org-publishing.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [string] $token
3 | )
4 |
5 |
6 | . $PSScriptRoot\pipeline-logging-functions.ps1
7 |
8 | # Write-PipelineSetVariable will no-op if a variable named $ci is not defined
9 | # Since this script is only ever called in AzDO builds, just universally set it
10 | $ci = $true
11 |
12 | Write-PipelineSetVariable -Name 'VSS_NUGET_ACCESSTOKEN' -Value $token -IsMultiJobVariable $false
13 | Write-PipelineSetVariable -Name 'VSS_NUGET_URI_PREFIXES' -Value 'https://dnceng.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/dnceng/;https://devdiv.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/devdiv/' -IsMultiJobVariable $false
14 |
--------------------------------------------------------------------------------
/eng/common/generate-sbom-prep.ps1:
--------------------------------------------------------------------------------
1 | Param(
2 | [Parameter(Mandatory=$true)][string] $ManifestDirPath # Manifest directory where sbom will be placed
3 | )
4 |
5 | . $PSScriptRoot\pipeline-logging-functions.ps1
6 |
7 | # Normally - we'd listen to the manifest path given, but 1ES templates will overwrite if this level gets uploaded directly
8 | # with their own overwriting ours. So we create it as a sub directory of the requested manifest path.
9 | $ArtifactName = "${env:SYSTEM_STAGENAME}_${env:AGENT_JOBNAME}_SBOM"
10 | $SafeArtifactName = $ArtifactName -replace '["/:<>\\|?@*"() ]', '_'
11 | $SbomGenerationDir = Join-Path $ManifestDirPath $SafeArtifactName
12 |
13 | Write-Host "Artifact name before : $ArtifactName"
14 | Write-Host "Artifact name after : $SafeArtifactName"
15 |
16 | Write-Host "Creating dir $ManifestDirPath"
17 |
18 | # create directory for sbom manifest to be placed
19 | if (!(Test-Path -path $SbomGenerationDir))
20 | {
21 | New-Item -ItemType Directory -path $SbomGenerationDir
22 | Write-Host "Successfully created directory $SbomGenerationDir"
23 | }
24 | else{
25 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder."
26 | }
27 |
28 | Write-Host "Updating artifact name"
29 | Write-Host "##vso[task.setvariable variable=ARTIFACT_NAME]$SafeArtifactName"
30 |
--------------------------------------------------------------------------------
/eng/common/helixpublish.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | msbuild
6 |
7 |
8 |
9 |
10 | %(Identity)
11 |
12 |
13 |
14 |
15 |
16 | $(WorkItemDirectory)
17 | $(WorkItemCommand)
18 | $(WorkItemTimeout)
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/eng/common/init-tools-native.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -command "& """%~dp0init-tools-native.ps1""" %*"
3 | exit /b %ErrorLevel%
--------------------------------------------------------------------------------
/eng/common/internal/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | false
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/eng/common/internal/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/eng/common/msbuild.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(PositionalBinding=$false)]
2 | Param(
3 | [string] $verbosity = 'minimal',
4 | [bool] $warnAsError = $true,
5 | [bool] $nodeReuse = $true,
6 | [switch] $ci,
7 | [switch] $prepareMachine,
8 | [switch] $excludePrereleaseVS,
9 | [string] $msbuildEngine = $null,
10 | [Parameter(ValueFromRemainingArguments=$true)][String[]]$extraArgs
11 | )
12 |
13 | . $PSScriptRoot\tools.ps1
14 |
15 | try {
16 | if ($ci) {
17 | $nodeReuse = $false
18 | }
19 |
20 | MSBuild @extraArgs
21 | }
22 | catch {
23 | Write-Host $_.ScriptStackTrace
24 | Write-PipelineTelemetryError -Category 'Build' -Message $_
25 | ExitWithExitCode 1
26 | }
27 |
28 | ExitWithExitCode 0
--------------------------------------------------------------------------------
/eng/common/msbuild.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 |
5 | # resolve $source until the file is no longer a symlink
6 | while [[ -h "$source" ]]; do
7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8 | source="$(readlink "$source")"
9 | # if $source was a relative symlink, we need to resolve it relative to the path where the
10 | # symlink file was located
11 | [[ $source != /* ]] && source="$scriptroot/$source"
12 | done
13 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
14 |
15 | verbosity='minimal'
16 | warn_as_error=true
17 | node_reuse=true
18 | prepare_machine=false
19 | extra_args=''
20 |
21 | while (($# > 0)); do
22 | lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
23 | case $lowerI in
24 | --verbosity)
25 | verbosity=$2
26 | shift 2
27 | ;;
28 | --warnaserror)
29 | warn_as_error=$2
30 | shift 2
31 | ;;
32 | --nodereuse)
33 | node_reuse=$2
34 | shift 2
35 | ;;
36 | --ci)
37 | ci=true
38 | shift 1
39 | ;;
40 | --preparemachine)
41 | prepare_machine=true
42 | shift 1
43 | ;;
44 | *)
45 | extra_args="$extra_args $1"
46 | shift 1
47 | ;;
48 | esac
49 | done
50 |
51 | . "$scriptroot/tools.sh"
52 |
53 | if [[ "$ci" == true ]]; then
54 | node_reuse=false
55 | fi
56 |
57 | MSBuild $extra_args
58 | ExitWithExitCode 0
59 |
--------------------------------------------------------------------------------
/eng/common/post-build/nuget-validation.ps1:
--------------------------------------------------------------------------------
1 | # This script validates NuGet package metadata information using this
2 | # tool: https://github.com/NuGet/NuGetGallery/tree/jver-verify/src/VerifyMicrosoftPackage
3 |
4 | param(
5 | [Parameter(Mandatory=$true)][string] $PackagesPath # Path to where the packages to be validated are
6 | )
7 |
8 | # `tools.ps1` checks $ci to perform some actions. Since the post-build
9 | # scripts don't necessarily execute in the same agent that run the
10 | # build.ps1/sh script this variable isn't automatically set.
11 | $ci = $true
12 | $disableConfigureToolsetImport = $true
13 | . $PSScriptRoot\..\tools.ps1
14 |
15 | try {
16 | & $PSScriptRoot\nuget-verification.ps1 ${PackagesPath}\*.nupkg
17 | }
18 | catch {
19 | Write-Host $_.ScriptStackTrace
20 | Write-PipelineTelemetryError -Category 'NuGetValidation' -Message $_
21 | ExitWithExitCode 1
22 | }
23 |
--------------------------------------------------------------------------------
/eng/common/retain-build.ps1:
--------------------------------------------------------------------------------
1 |
2 | Param(
3 | [Parameter(Mandatory=$true)][int] $buildId,
4 | [Parameter(Mandatory=$true)][string] $azdoOrgUri,
5 | [Parameter(Mandatory=$true)][string] $azdoProject,
6 | [Parameter(Mandatory=$true)][string] $token
7 | )
8 |
9 | $ErrorActionPreference = 'Stop'
10 | Set-StrictMode -Version 2.0
11 |
12 | function Get-AzDOHeaders(
13 | [string] $token)
14 | {
15 | $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":${token}"))
16 | $headers = @{"Authorization"="Basic $base64AuthInfo"}
17 | return $headers
18 | }
19 |
20 | function Update-BuildRetention(
21 | [string] $azdoOrgUri,
22 | [string] $azdoProject,
23 | [int] $buildId,
24 | [string] $token)
25 | {
26 | $headers = Get-AzDOHeaders -token $token
27 | $requestBody = "{
28 | `"keepForever`": `"true`"
29 | }"
30 |
31 | $requestUri = "${azdoOrgUri}/${azdoProject}/_apis/build/builds/${buildId}?api-version=6.0"
32 | write-Host "Attempting to retain build using the following URI: ${requestUri} ..."
33 |
34 | try {
35 | Invoke-RestMethod -Uri $requestUri -Method Patch -Body $requestBody -Header $headers -contentType "application/json"
36 | Write-Host "Updated retention settings for build ${buildId}."
37 | }
38 | catch {
39 | Write-Error "Failed to update retention settings for build: $_.Exception.Response.StatusDescription"
40 | exit 1
41 | }
42 | }
43 |
44 | Update-BuildRetention -azdoOrgUri $azdoOrgUri -azdoProject $azdoProject -buildId $buildId -token $token
45 | exit 0
46 |
--------------------------------------------------------------------------------
/eng/common/sdl/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/eng/common/sdl/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/eng/common/sdl/sdl.ps1:
--------------------------------------------------------------------------------
1 |
2 | function Install-Gdn {
3 | param(
4 | [Parameter(Mandatory=$true)]
5 | [string]$Path,
6 |
7 | # If omitted, install the latest version of Guardian, otherwise install that specific version.
8 | [string]$Version
9 | )
10 |
11 | $ErrorActionPreference = 'Stop'
12 | Set-StrictMode -Version 2.0
13 | $disableConfigureToolsetImport = $true
14 | $global:LASTEXITCODE = 0
15 |
16 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
17 | # scripts don't necessarily execute in the same agent that run the
18 | # build.ps1/sh script this variable isn't automatically set.
19 | $ci = $true
20 | . $PSScriptRoot\..\tools.ps1
21 |
22 | $argumentList = @("install", "Microsoft.Guardian.Cli", "-Source https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json", "-OutputDirectory $Path", "-NonInteractive", "-NoCache")
23 |
24 | if ($Version) {
25 | $argumentList += "-Version $Version"
26 | }
27 |
28 | Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait
29 |
30 | $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path
31 |
32 | if (!$gdnCliPath)
33 | {
34 | Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian'
35 | }
36 |
37 | return $gdnCliPath.FullName
38 | }
--------------------------------------------------------------------------------
/eng/common/templates-official/job/onelocbuild.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/onelocbuild.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/job/publish-build-assets.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/publish-build-assets.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/job/source-build.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/source-build.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/job/source-index-stage1.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/source-index-stage1.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/jobs/codeql-build.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/jobs/codeql-build.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/jobs/jobs.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/jobs/jobs.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/jobs/source-build.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/jobs/source-build.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates-official/post-build/common-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - template: /eng/common/core-templates/post-build/common-variables.yml
3 | parameters:
4 | # Specifies whether to use 1ES
5 | is1ESPipeline: true
6 |
7 | ${{ each parameter in parameters }}:
8 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates-official/post-build/post-build.yml:
--------------------------------------------------------------------------------
1 | stages:
2 | - template: /eng/common/core-templates/post-build/post-build.yml
3 | parameters:
4 | # Specifies whether to use 1ES
5 | is1ESPipeline: true
6 |
7 | ${{ each parameter in parameters }}:
8 | ${{ parameter.key }}: ${{ parameter.value }}
9 |
--------------------------------------------------------------------------------
/eng/common/templates-official/post-build/setup-maestro-vars.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml
3 | parameters:
4 | # Specifies whether to use 1ES
5 | is1ESPipeline: true
6 |
7 | ${{ each parameter in parameters }}:
8 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/component-governance.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/component-governance.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/enable-internal-runtimes.yml:
--------------------------------------------------------------------------------
1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64'
2 | # variable with the base64-encoded SAS token, by default
3 | steps:
4 | - template: /eng/common/core-templates/steps/enable-internal-runtimes.yml
5 | parameters:
6 | is1ESPipeline: true
7 |
8 | ${{ each parameter in parameters }}:
9 | ${{ parameter.key }}: ${{ parameter.value }}
10 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/enable-internal-sources.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/enable-internal-sources.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/generate-sbom.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/generate-sbom.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/get-delegation-sas.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/get-federated-access-token.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/get-federated-access-token.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/publish-build-artifacts.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: displayName
3 | type: string
4 | default: 'Publish to Build Artifact'
5 |
6 | - name: condition
7 | type: string
8 | default: succeeded()
9 |
10 | - name: artifactName
11 | type: string
12 |
13 | - name: pathToPublish
14 | type: string
15 |
16 | - name: continueOnError
17 | type: boolean
18 | default: false
19 |
20 | - name: publishLocation
21 | type: string
22 | default: 'Container'
23 |
24 | - name: is1ESPipeline
25 | type: boolean
26 | default: true
27 |
28 | steps:
29 | - ${{ if ne(parameters.is1ESPipeline, true) }}:
30 | - 'eng/common/templates-official cannot be referenced from a non-1ES managed template': error
31 | - task: 1ES.PublishBuildArtifacts@1
32 | displayName: ${{ parameters.displayName }}
33 | condition: ${{ parameters.condition }}
34 | ${{ if parameters.continueOnError }}:
35 | continueOnError: ${{ parameters.continueOnError }}
36 | inputs:
37 | PublishLocation: ${{ parameters.publishLocation }}
38 | PathtoPublish: ${{ parameters.pathToPublish }}
39 | ${{ if parameters.artifactName }}:
40 | ArtifactName: ${{ parameters.artifactName }}
41 |
42 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/publish-logs.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/publish-logs.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/publish-pipeline-artifacts.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: is1ESPipeline
3 | type: boolean
4 | default: true
5 |
6 | - name: args
7 | type: object
8 | default: {}
9 |
10 | steps:
11 | - ${{ if ne(parameters.is1ESPipeline, true) }}:
12 | - 'eng/common/templates-official cannot be referenced from a non-1ES managed template': error
13 | - task: 1ES.PublishPipelineArtifact@1
14 | displayName: ${{ coalesce(parameters.args.displayName, 'Publish to Build Artifact') }}
15 | ${{ if parameters.args.condition }}:
16 | condition: ${{ parameters.args.condition }}
17 | ${{ else }}:
18 | condition: succeeded()
19 | ${{ if parameters.args.continueOnError }}:
20 | continueOnError: ${{ parameters.args.continueOnError }}
21 | inputs:
22 | targetPath: ${{ parameters.args.targetPath }}
23 | ${{ if parameters.args.artifactName }}:
24 | artifactName: ${{ parameters.args.artifactName }}
25 | ${{ if parameters.args.properties }}:
26 | properties: ${{ parameters.args.properties }}
27 | ${{ if parameters.args.sbomEnabled }}:
28 | sbomEnabled: ${{ parameters.args.sbomEnabled }}
29 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/retain-build.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/retain-build.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/send-to-helix.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/send-to-helix.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/source-build.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/source-build.yml
3 | parameters:
4 | is1ESPipeline: true
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates-official/variables/sdl-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
3 | # sync with the packages.config file.
4 | - name: DefaultGuardianVersion
5 | value: 0.109.0
6 | - name: GuardianPackagesConfigFile
7 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
--------------------------------------------------------------------------------
/eng/common/templates/job/onelocbuild.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/onelocbuild.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/job/publish-build-assets.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/publish-build-assets.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/job/source-build.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/source-build.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/job/source-index-stage1.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/job/source-index-stage1.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/jobs/codeql-build.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/jobs/codeql-build.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/jobs/jobs.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/jobs/jobs.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/jobs/source-build.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: /eng/common/core-templates/jobs/source-build.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates/post-build/common-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - template: /eng/common/core-templates/post-build/common-variables.yml
3 | parameters:
4 | # Specifies whether to use 1ES
5 | is1ESPipeline: false
6 |
7 | ${{ each parameter in parameters }}:
8 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates/post-build/post-build.yml:
--------------------------------------------------------------------------------
1 | stages:
2 | - template: /eng/common/core-templates/post-build/post-build.yml
3 | parameters:
4 | # Specifies whether to use 1ES
5 | is1ESPipeline: false
6 |
7 | ${{ each parameter in parameters }}:
8 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates/post-build/setup-maestro-vars.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml
3 | parameters:
4 | # Specifies whether to use 1ES
5 | is1ESPipeline: false
6 |
7 | ${{ each parameter in parameters }}:
8 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates/steps/component-governance.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/component-governance.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/enable-internal-runtimes.yml:
--------------------------------------------------------------------------------
1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64'
2 | # variable with the base64-encoded SAS token, by default
3 |
4 | steps:
5 | - template: /eng/common/core-templates/steps/enable-internal-runtimes.yml
6 | parameters:
7 | is1ESPipeline: false
8 |
9 | ${{ each parameter in parameters }}:
10 | ${{ parameter.key }}: ${{ parameter.value }}
11 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/enable-internal-sources.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/enable-internal-sources.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates/steps/generate-sbom.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/generate-sbom.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/get-delegation-sas.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/get-federated-access-token.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/get-federated-access-token.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
--------------------------------------------------------------------------------
/eng/common/templates/steps/publish-build-artifacts.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: is1ESPipeline
3 | type: boolean
4 | default: false
5 |
6 | - name: displayName
7 | type: string
8 | default: 'Publish to Build Artifact'
9 |
10 | - name: condition
11 | type: string
12 | default: succeeded()
13 |
14 | - name: artifactName
15 | type: string
16 |
17 | - name: pathToPublish
18 | type: string
19 |
20 | - name: continueOnError
21 | type: boolean
22 | default: false
23 |
24 | - name: publishLocation
25 | type: string
26 | default: 'Container'
27 |
28 | steps:
29 | - ${{ if eq(parameters.is1ESPipeline, true) }}:
30 | - 'eng/common/templates cannot be referenced from a 1ES managed template': error
31 | - task: PublishBuildArtifacts@1
32 | displayName: ${{ parameters.displayName }}
33 | condition: ${{ parameters.condition }}
34 | ${{ if parameters.continueOnError }}:
35 | continueOnError: ${{ parameters.continueOnError }}
36 | inputs:
37 | PublishLocation: ${{ parameters.publishLocation }}
38 | PathtoPublish: ${{ parameters.pathToPublish }}
39 | ${{ if parameters.artifactName }}:
40 | ArtifactName: ${{ parameters.artifactName }}
--------------------------------------------------------------------------------
/eng/common/templates/steps/publish-logs.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/publish-logs.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/publish-pipeline-artifacts.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: is1ESPipeline
3 | type: boolean
4 | default: false
5 |
6 | - name: args
7 | type: object
8 | default: {}
9 |
10 | steps:
11 | - ${{ if eq(parameters.is1ESPipeline, true) }}:
12 | - 'eng/common/templates cannot be referenced from a 1ES managed template': error
13 | - task: PublishPipelineArtifact@1
14 | displayName: ${{ coalesce(parameters.args.displayName, 'Publish to Build Artifact') }}
15 | ${{ if parameters.args.condition }}:
16 | condition: ${{ parameters.args.condition }}
17 | ${{ else }}:
18 | condition: succeeded()
19 | ${{ if parameters.args.continueOnError }}:
20 | continueOnError: ${{ parameters.args.continueOnError }}
21 | inputs:
22 | targetPath: ${{ parameters.args.targetPath }}
23 | ${{ if parameters.args.artifactName }}:
24 | artifactName: ${{ parameters.args.artifactName }}
25 | ${{ if parameters.args.publishLocation }}:
26 | publishLocation: ${{ parameters.args.publishLocation }}
27 | ${{ if parameters.args.fileSharePath }}:
28 | fileSharePath: ${{ parameters.args.fileSharePath }}
29 | ${{ if parameters.args.Parallel }}:
30 | parallel: ${{ parameters.args.Parallel }}
31 | ${{ if parameters.args.parallelCount }}:
32 | parallelCount: ${{ parameters.args.parallelCount }}
33 | ${{ if parameters.args.properties }}:
34 | properties: ${{ parameters.args.properties }}
--------------------------------------------------------------------------------
/eng/common/templates/steps/retain-build.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/retain-build.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/send-to-helix.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/send-to-helix.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/source-build.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - template: /eng/common/core-templates/steps/source-build.yml
3 | parameters:
4 | is1ESPipeline: false
5 |
6 | ${{ each parameter in parameters }}:
7 | ${{ parameter.key }}: ${{ parameter.value }}
8 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "tools": {
3 | "dotnet": "9.0.106",
4 | "runtimes": {
5 | "dotnet": [
6 | "8.0.12"
7 | ]
8 | }
9 | },
10 | "msbuild-sdks": {
11 | "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25271.1"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/repack.ps1:
--------------------------------------------------------------------------------
1 |
2 | # clean up the previously-cached NuGet packages
3 | Remove-Item -Recurse ~\.nuget\packages\System.CommandLine* -Force
4 |
5 | # build and pack dotnet-interactive
6 | dotnet clean
7 | dotnet pack /p:PackageVersion=2.0.0-dev
8 |
9 | # copy the dotnet-interactive packages to the temp directory
10 | Get-ChildItem -Recurse -Filter *.nupkg | Copy-Item -Destination c:\temp -Force
11 |
12 |
--------------------------------------------------------------------------------
/samples/DragonFruit/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/DragonFruit/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/DragonFruit/DragonFruit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | $(TargetFrameworkForNETSDK)
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/DragonFruit/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace DragonFruit
7 | {
8 | class Program
9 | {
10 | ///
11 | /// DragonFruit simple example program
12 | ///
13 | /// Show verbose output
14 | /// Which flavor to use
15 | /// How many smoothies?
16 | static int Main(
17 | bool verbose,
18 | string flavor = "chocolate",
19 | int count = 1)
20 | {
21 | if (verbose)
22 | {
23 | Console.WriteLine("Running in verbose mode");
24 | }
25 | Console.WriteLine($"Creating {count} banana {(count == 1 ? "smoothie" : "smoothies")} with {flavor}");
26 | return 0;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/samples/HostingPlayground/Greeter.cs:
--------------------------------------------------------------------------------
1 | namespace HostingPlayground
2 | {
3 | public class Greeter : IGreeter
4 | {
5 |
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/samples/HostingPlayground/GreeterOptions.cs:
--------------------------------------------------------------------------------
1 | namespace HostingPlayground
2 | {
3 | public class GreeterOptions
4 | {
5 | public string Name { get; }
6 |
7 | public GreeterOptions(string name)
8 | {
9 | Name = name;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/samples/HostingPlayground/HostingPlayground.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | $(TargetFrameworkForNETSDK)
6 | true
7 | $(NoWarn);CS1591
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/HostingPlayground/HostingPlaygroundLogEvents.cs:
--------------------------------------------------------------------------------
1 | namespace HostingPlayground
2 | {
3 | public class HostingPlaygroundLogEvents
4 | {
5 | public const int GreetEvent = 1000;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/samples/HostingPlayground/IGreeter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace HostingPlayground
4 | {
5 | interface IGreeter
6 | {
7 | void Greet(string name) => Console.WriteLine($"Hello, {name ?? "anonymous"}");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/samples/HostingPlayground/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/RenderingPlayground/Colorizer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.CommandLine.Rendering;
5 |
6 | namespace RenderingPlayground
7 | {
8 | internal static class Colorizer
9 | {
10 | public static TextSpan Underline(this string value) =>
11 | new ContainerSpan(StyleSpan.UnderlinedOn(),
12 | new ContentSpan(value),
13 | StyleSpan.UnderlinedOff());
14 |
15 |
16 | public static TextSpan Rgb(this string value, byte r, byte g, byte b) =>
17 | new ContainerSpan(ForegroundColorSpan.Rgb(r, g, b),
18 | new ContentSpan(value),
19 | ForegroundColorSpan.Reset());
20 |
21 | public static TextSpan LightGreen(this string value) =>
22 | new ContainerSpan(ForegroundColorSpan.LightGreen(),
23 | new ContentSpan(value),
24 | ForegroundColorSpan.Reset());
25 |
26 | public static TextSpan White(this string value) =>
27 | new ContainerSpan(ForegroundColorSpan.White(),
28 | new ContentSpan(value),
29 | ForegroundColorSpan.Reset());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/samples/RenderingPlayground/ColorsView.cs:
--------------------------------------------------------------------------------
1 | using System.CommandLine.Rendering;
2 | using System.CommandLine.Rendering.Views;
3 |
4 | namespace RenderingPlayground
5 | {
6 | internal class ColorsView : View
7 | {
8 | public ColorsView(string text)
9 | {
10 | Text = text;
11 | }
12 |
13 | private string Text { get; }
14 |
15 | public override Size Measure(ConsoleRenderer renderer, Size maxSize) => maxSize;
16 |
17 | public override void Render(ConsoleRenderer renderer, Region region)
18 | {
19 | byte r = 0;
20 | byte g = 0;
21 | byte b = 0;
22 |
23 | var i = 0;
24 |
25 | for (var x = 0; x < region.Width; x++)
26 | for (var y = 0; y < region.Height; y++)
27 | {
28 | if (i >= Text.Length - 1)
29 | {
30 | i = 0;
31 | }
32 | else
33 | {
34 | i++;
35 | }
36 |
37 | var subregion = new Region(
38 | region.Left + x,
39 | region.Top + y,
40 | 1,
41 | 1);
42 |
43 | unchecked
44 | {
45 | renderer.RenderToRegion(
46 | $"{ForegroundColorSpan.Rgb(r += 2, g += 3, b += 5)}{Text[i]}{ForegroundColorSpan.Reset()}",
47 | subregion);
48 | }
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/samples/RenderingPlayground/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/samples/RenderingPlayground/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/RenderingPlayground/RenderingPlayground.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | $(TargetFrameworkForNETSDK)
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/samples/RenderingPlayground/SampleName.cs:
--------------------------------------------------------------------------------
1 | namespace RenderingPlayground
2 | {
3 | internal enum SampleName
4 | {
5 | Colors,
6 | Dir,
7 | Moby,
8 | Processes,
9 | TableView,
10 | Clock,
11 | GridLayout,
12 | Cursor,
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/sourcebuild.slnf:
--------------------------------------------------------------------------------
1 | {
2 | "solution": {
3 | "path": "System.CommandLine.sln",
4 | "projects": [
5 | "src\\System.CommandLine\\System.CommandLine.csproj",
6 | "src\\System.CommandLine.DragonFruit\\System.CommandLine.DragonFruit.csproj",
7 | "src\\System.CommandLine.NamingConventionBinder\\System.CommandLine.NamingConventionBinder.csproj",
8 | "src\\System.CommandLine.Rendering\\System.CommandLine.Rendering.csproj"
9 | ]
10 | }
11 | }
--------------------------------------------------------------------------------
/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.CommandLine.Hosting;
5 | using System.CommandLine.NamingConventionBinder;
6 | using ApprovalTests;
7 | using ApprovalTests.Reporters;
8 | using Xunit;
9 |
10 | namespace System.CommandLine.ApiCompatibility.Tests;
11 |
12 | public class ApiCompatibilityApprovalTests
13 | {
14 | [Fact]
15 | [UseReporter(typeof(DiffReporter))]
16 | public void System_CommandLine_api_is_not_changed()
17 | {
18 | var contract = ApiContract.GenerateContractForAssembly(typeof(ParseResult).Assembly);
19 | Approvals.Verify(contract);
20 | }
21 |
22 | [Fact]
23 | [UseReporter(typeof(DiffReporter))]
24 | public void System_CommandLine_Hosting_api_is_not_changed()
25 | {
26 | var contract = ApiContract.GenerateContractForAssembly(typeof(HostingExtensions).Assembly);
27 | Approvals.Verify(contract);
28 | }
29 |
30 | [Fact]
31 | [UseReporter(typeof(DiffReporter))]
32 | public void System_CommandLine_NamingConventionBinder_api_is_not_changed()
33 | {
34 | var contract = ApiContract.GenerateContractForAssembly(typeof(ModelBindingCommandHandler).Assembly);
35 | Approvals.Verify(contract);
36 | }
37 | }
--------------------------------------------------------------------------------
/src/System.CommandLine.ApiCompatibility.Tests/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | IDE1006
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/System.CommandLine.ApiCompatibility.Tests/LocalizationTests.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using System.Linq;
3 | using Xunit;
4 |
5 | namespace System.CommandLine.ApiCompatibility.Tests
6 | {
7 | public class LocalizationTests
8 | {
9 | private const string CommandName = "the-command";
10 |
11 | [Theory]
12 | [InlineData("es", $"Falta el argumento requerido para el comando: '{CommandName}'.")]
13 | [InlineData("en-US", $"Required argument missing for command: '{CommandName}'.")]
14 | public void ErrorMessages_AreLocalized(string cultureName, string expectedMessage)
15 | {
16 | CultureInfo uiCultureBefore = CultureInfo.CurrentUICulture;
17 |
18 | try
19 | {
20 | CultureInfo.CurrentUICulture = new CultureInfo(cultureName);
21 |
22 | Command command = new(CommandName)
23 | {
24 | new Argument("arg")
25 | };
26 |
27 | ParseResult parseResult = command.Parse(CommandName);
28 |
29 | Assert.Equal(expectedMessage, parseResult.Errors.Single().Message);
30 | }
31 | finally
32 | {
33 | CultureInfo.CurrentUICulture = uiCultureBefore;
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/System.CommandLine.ApiCompatibility.Tests/System.CommandLine.ApiCompatibility.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(TargetFrameworkForNETSDK)
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Benchmarks/Categories.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace System.CommandLine.Benchmarks
5 | {
6 | public static class Categories
7 | {
8 | public const string CommandLine = "CommandLine";
9 | public const string DragonFruit = "DragonFruit";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Benchmarks/Helpers/BdnParam.cs:
--------------------------------------------------------------------------------
1 | namespace System.CommandLine.Benchmarks.Helpers
2 | {
3 | ///
4 | /// Wraps instance of type and
5 | /// returns a separately provided comment to the instance when DotnetBenchmark logs results.
6 | ///
7 | ///
8 | /// The purpose of this wrapper is to increase the readability of DotnetBenchmark outputs.
9 | ///
10 | public class BdnParam
11 | {
12 | public T Value { get; }
13 | private readonly string _comment;
14 |
15 | public BdnParam(T value, string comment)
16 | {
17 | Value = value;
18 | _comment = comment;
19 | }
20 |
21 | public override string ToString()
22 | {
23 | return _comment;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Benchmarks/Helpers/NullStreamWriter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.CommandLine.IO;
5 |
6 | namespace System.CommandLine.Benchmarks.Helpers
7 | {
8 | internal class NullStreamWriter : IStandardStreamWriter
9 | {
10 | public void Write(string value)
11 | {
12 | // do nothing
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Benchmarks/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using BenchmarkDotNet.Running;
5 | using System.Linq;
6 | using BenchmarkDotNet.Configs;
7 | using System.Collections.Immutable;
8 | using System.IO;
9 |
10 | namespace System.CommandLine.Benchmarks
11 | {
12 | class Program
13 | {
14 | static int Main(string[] args)
15 | {
16 | var result = BenchmarkSwitcher
17 | .FromAssembly(typeof(Program).Assembly)
18 | #if DEBUG
19 | .Run(args, new DebugInProcessConfig());
20 | Console.ReadLine();
21 | #else
22 | .Run(args, RecommendedConfig.Create(
23 | artifactsPath: new DirectoryInfo(Path.Combine(
24 | Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
25 | mandatoryCategories: ImmutableHashSet.Create(Categories.CommandLine, Categories.DragonFruit)));
26 | #endif
27 | // an empty summary means that initial filtering and validation did not allow to run
28 | if (!result.Any())
29 | return 1;
30 |
31 | // if anything has failed, it's an error
32 | if (result.Any(summary => summary.HasCriticalValidationErrors || summary.Reports.Any(report => !report.BuildResult.IsBuildSuccess || !report.ExecuteResults.Any())))
33 | return 1;
34 |
35 | return 0;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Benchmarks/System.CommandLine.Benchmarks.net5.0.v3.ncrunchproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | True
4 |
5 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Benchmarks/System.CommandLine.Benchmarks.v3.ncrunchproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | True
4 |
5 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit.Tests/EntryPointCreatorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Reflection;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace System.CommandLine.DragonFruit.Tests
10 | {
11 | public class EntryPointCreatorTests
12 | {
13 | [Fact]
14 | public void ItThrowsIfEntryPointNotFound()
15 | {
16 | Action find = () => EntryPointDiscoverer.FindStaticEntryMethod(typeof(IEnumerable<>).Assembly);
17 | find.Should().Throw();
18 | }
19 |
20 | private class Program
21 | {
22 | public static void Main(string arg1) { }
23 | public static void Main(string arg2, string arg3) { }
24 | }
25 |
26 | [Fact]
27 | public void ItThrowsIfMultipleEntryPointNotFound()
28 | {
29 | Action find = () => EntryPointDiscoverer.FindStaticEntryMethod(typeof(CommandLineTests).Assembly);
30 | find.Should().Throw();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit.Tests/StringExtensionTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using FluentAssertions;
5 | using Xunit;
6 |
7 | namespace System.CommandLine.DragonFruit.Tests
8 | {
9 | public class StringExtensionTests
10 | {
11 | [Theory]
12 | [InlineData(null, null)]
13 | [InlineData("", "")]
14 | [InlineData("Option123", "option123")]
15 | [InlineData("dWORD", "d-word")]
16 | [InlineData("MSBuild", "msbuild")]
17 | [InlineData("NoEdit", "no-edit")]
18 | [InlineData("SetUpstreamBranch", "set-upstream-branch")]
19 | [InlineData("lowerCaseFirst", "lower-case-first")]
20 | [InlineData("_field", "field")]
21 | [InlineData("__field", "field")]
22 | [InlineData("___field", "field")]
23 | [InlineData("m_field", "m-field")]
24 | [InlineData("m_Field", "m-field")]
25 | public void ToKebabCase(string input, string expected) => input.ToKebabCase().Should().Be(expected);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit.Tests/System.CommandLine.DragonFruit.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(TargetFrameworkForNETSDK)
5 | AutoGeneratedProgram
6 |
7 | true
8 |
9 |
10 |
11 | $(NoWarn);1701;1702;1591
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit/CommandHelpMetadata.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace System.CommandLine.DragonFruit
7 | {
8 | public class CommandHelpMetadata
9 | {
10 | public string Description { get; set; }
11 |
12 | public string Name { get; set; }
13 |
14 | public Dictionary ParameterDescriptions { get; } = new Dictionary();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit/System.CommandLine.DragonFruit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | netstandard2.0
5 | This package includes the experimental DragonFruit app model for System.CommandLine, which allows you to create a command line application using only a Main method while getting support for complex type binding, error reporting, help, shell completions, and more.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/System.CommandLine.DragonFruit/targets/System.CommandLine.DragonFruit.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 |
8 | true
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator.CommandHandler/CommandExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace System.CommandLine;
2 |
3 | ///
4 | /// Provides extension methods for .
5 | ///
6 | public static class CommandExtensions
7 | {
8 | private const string _messageForWhenGeneratorIsNotInUse =
9 | "This overload should not be called. You should reference the System.CommandLine.Generator package which will generate a more specific overload for your delegate.";
10 |
11 | ///
12 | /// Sets a command handler.
13 | ///
14 | /// Currently, this method only works with C# source generators.
15 | /// The command on which to set the handler.
16 | /// A delegate implementing the handler for the command.
17 | /// The symbols used to bind the handler's parameters.
18 | public static void SetHandler(
19 | this Command command,
20 | TDelegate @delegate,
21 | params Symbol[] symbols)
22 | {
23 | throw new InvalidOperationException(_messageForWhenGeneratorIsNotInUse);
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator.CommandHandler/System.CommandLine.Generator.CommandHandler.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator.Tests/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | IDE1006
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator.Tests/System.CommandLine.Generator.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(TargetFrameworkForNETSDK);$(NetFrameworkCurrent)
5 | true
6 | true
7 | true
8 | enable
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Invocations/ReturnPattern.cs:
--------------------------------------------------------------------------------
1 | namespace System.CommandLine.Generator.Invocations
2 | {
3 | internal enum ReturnPattern
4 | {
5 | None,
6 | InvocationContextExitCode,
7 | FunctionReturnValue,
8 | AwaitFunction,
9 | AwaitFunctionReturnValue
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Parameters/ArgumentParameter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace System.CommandLine.Generator.Parameters
4 | {
5 | internal class ArgumentParameter : PropertyParameter, IEquatable
6 | {
7 | public ArgumentParameter(string localName, INamedTypeSymbol type, ITypeSymbol valueType)
8 | : base(localName, type, valueType)
9 | {
10 | }
11 |
12 | public override string GetValueFromContext()
13 | => $"context.GetValue({LocalName})";
14 |
15 | public override int GetHashCode()
16 | => base.GetHashCode();
17 |
18 | public override bool Equals(object? obj)
19 | => Equals(obj as ArgumentParameter);
20 |
21 | public bool Equals(ArgumentParameter? other)
22 | {
23 | if (other is null) return false;
24 | return base.Equals(other);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Parameters/BindingContextParameter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace System.CommandLine.Generator.Parameters
4 | {
5 | internal class BindingContextParameter : Parameter, IEquatable
6 | {
7 | public BindingContextParameter(ITypeSymbol bindingContextType)
8 | : base(bindingContextType)
9 | {
10 | }
11 |
12 | public override string GetValueFromContext()
13 | => "context.GetBindingContext()";
14 |
15 | public override int GetHashCode()
16 | => base.GetHashCode();
17 |
18 | public override bool Equals(object? obj)
19 | => Equals(obj as BindingContextParameter);
20 |
21 | public bool Equals(BindingContextParameter? other)
22 | {
23 | if (other is null) return false;
24 | return base.Equals(other);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Parameters/ConsoleParameter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace System.CommandLine.Generator.Parameters
4 | {
5 | internal class ConsoleParameter : Parameter, IEquatable
6 | {
7 | public ConsoleParameter(ITypeSymbol consoleType)
8 | : base(consoleType)
9 | {
10 | }
11 |
12 | public override string GetValueFromContext()
13 | => "context.Console";
14 |
15 | public override int GetHashCode()
16 | => base.GetHashCode();
17 |
18 | public override bool Equals(object? obj)
19 | => Equals(obj as ConsoleParameter);
20 |
21 | public bool Equals(ConsoleParameter? other)
22 | {
23 | if (other is null) return false;
24 | return base.Equals(other);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Parameters/OptionParameter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace System.CommandLine.Generator.Parameters
4 | {
5 |
6 | internal class OptionParameter : PropertyParameter, IEquatable
7 | {
8 | public OptionParameter(string localName, INamedTypeSymbol type, ITypeSymbol valueType)
9 | : base(localName, type, valueType)
10 | {
11 | }
12 |
13 | public override string GetValueFromContext()
14 | => $"context.GetValue({LocalName})";
15 |
16 | public override int GetHashCode()
17 | => base.GetHashCode();
18 |
19 | public override bool Equals(object? obj)
20 | => Equals(obj as OptionParameter);
21 |
22 | public bool Equals(OptionParameter? other)
23 | {
24 | if (other is null) return false;
25 | return base.Equals(other);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Parameters/ParseResultParameter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace System.CommandLine.Generator.Parameters
4 | {
5 | internal class ParseResultParameter : Parameter, IEquatable
6 | {
7 | public ParseResultParameter(ITypeSymbol parseResultType)
8 | : base(parseResultType)
9 | {
10 | }
11 |
12 | public override string GetValueFromContext()
13 | => "context";
14 |
15 | public override int GetHashCode()
16 | => base.GetHashCode();
17 |
18 | public override bool Equals(object? obj)
19 | => Equals(obj as ParseResultParameter);
20 |
21 | public bool Equals(ParseResultParameter? other)
22 | {
23 | if (other is null) return false;
24 | return base.Equals(other);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/Parameters/RawParameter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 |
3 | namespace System.CommandLine.Generator.Parameters
4 | {
5 | internal class RawParameter : PropertyParameter, IEquatable
6 | {
7 | public RawParameter(string localName, ITypeSymbol valueType)
8 | : base(localName, valueType, valueType)
9 | {
10 | }
11 |
12 | public override string GetValueFromContext()
13 | => LocalName;
14 |
15 | public override int GetHashCode()
16 | => base.GetHashCode();
17 |
18 | public override bool Equals(object? obj)
19 | => Equals(obj as RawParameter);
20 |
21 | public bool Equals(RawParameter? other)
22 | {
23 | if (other is null) return false;
24 | return base.Equals(other);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Generator/System.CommandLine.Generator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | enable
6 | true
7 | false
8 | $(NoWarn);NU5128
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Hosting.Tests/System.CommandLine.Hosting.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(TargetFrameworkForNETSDK);$(NetFrameworkCurrent)
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Hosting/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Hosting/InvocationLifetimeOptions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Hosting;
2 |
3 | namespace System.CommandLine.Hosting
4 | {
5 | public class InvocationLifetimeOptions : ConsoleLifetimeOptions
6 | {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/System.CommandLine.Hosting/System.CommandLine.Hosting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | netstandard2.0;netstandard2.1;$(TargetFrameworkForNETSDK)
6 | This package provides support for using System.CommandLine with Microsoft.Extensions.Hosting.
7 |
8 |
9 |
10 | portable
11 |
12 |
13 |
14 | true
15 | true
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder.Tests/BindingTestSet.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace System.CommandLine.NamingConventionBinder.Tests;
7 |
8 | public class BindingTestSet : Dictionary<(Type type, string variationName), BindingTestCase>
9 | {
10 | public void Add(BindingTestCase testCase)
11 | {
12 | Add((testCase.ParameterType, testCase.VariationName), testCase);
13 | }
14 |
15 | public BindingTestCase this[Type type] => base[(type, null)];
16 | }
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder.Tests/ParameterDescriptorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.CommandLine.Tests.Binding;
5 | using System.Linq;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace System.CommandLine.NamingConventionBinder.Tests;
10 |
11 | public class ParameterDescriptorTests
12 | {
13 | [Theory]
14 | [InlineData(typeof(string), null)]
15 | [InlineData(typeof(int), 0)]
16 | [InlineData(typeof(int?), null)]
17 | public void GetDefaultValue_returns_the_default_for_the_type(Type type, object defaultValue)
18 | {
19 | type = typeof(ClassWithCtorParameter<>).MakeGenericType(type);
20 |
21 | var modelDescriptor = ModelDescriptor.FromType(type);
22 |
23 | modelDescriptor
24 | .ConstructorDescriptors
25 | .Single()
26 | .ParameterDescriptors
27 | .Single()
28 | .GetDefaultValue()
29 | .Should()
30 | .Be(defaultValue);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder.Tests/PropertyDescriptorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.CommandLine.Tests.Binding;
5 | using System.Linq;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace System.CommandLine.NamingConventionBinder.Tests;
10 |
11 | public class PropertyDescriptorTests
12 | {
13 | [Theory]
14 | [InlineData(typeof(string), null)]
15 | [InlineData(typeof(int), 0)]
16 | [InlineData(typeof(int?), null)]
17 | public void GetDefaultValue_returns_the_default_for_the_type(Type type, object defaultValue)
18 | {
19 | type = typeof(ClassWithSetter<>).MakeGenericType(type);
20 |
21 | var modelDescriptor = ModelDescriptor.FromType(type);
22 |
23 | modelDescriptor
24 | .PropertyDescriptors
25 | .Single()
26 | .GetDefaultValue()
27 | .Should()
28 | .Be(defaultValue);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder.Tests/System.CommandLine.NamingConventionBinder.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(TargetFrameworkForNETSDK);$(NetFrameworkCurrent)
5 | 10
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder/BindingHandler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.CommandLine.Binding;
5 | using System.CommandLine.Invocation;
6 |
7 | namespace System.CommandLine.NamingConventionBinder
8 | {
9 | ///
10 | /// Represents a handler that provides binding functionality for command-line actions.
11 | ///
12 | /// This abstract class serves as a base for implementing custom binding logic in command-line
13 | /// applications. It provides a mechanism to retrieve or initialize a for the current
14 | /// invocation.
15 | public abstract class BindingHandler : AsynchronousCommandLineAction
16 | {
17 | private BindingContext? _bindingContext;
18 |
19 | ///
20 | /// The binding context for the current invocation.
21 | ///
22 | public virtual BindingContext GetBindingContext(ParseResult parseResult)
23 | => _bindingContext ??= new BindingContext(parseResult);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder/BoundValue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace System.CommandLine.Binding
5 | {
6 | ///
7 | /// A value created by binding command line input.
8 | ///
9 | public readonly struct BoundValue
10 | {
11 | internal BoundValue(
12 | object? value,
13 | IValueDescriptor valueDescriptor,
14 | IValueSource valueSource)
15 | {
16 | Value = value;
17 | ValueDescriptor = valueDescriptor;
18 | ValueSource = valueSource;
19 | }
20 |
21 | ///
22 | /// The descriptor for the bound value.
23 | ///
24 | public IValueDescriptor ValueDescriptor { get; }
25 |
26 | ///
27 | /// The source from which the value was bound.
28 | ///
29 | public IValueSource ValueSource { get; }
30 |
31 | ///
32 | /// The value bound from the specified source.
33 | ///
34 | public object? Value { get; }
35 |
36 | ///
37 | public override string ToString() => $"{ValueDescriptor}: {Value}";
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/System.CommandLine.NamingConventionBinder/ConstructorDescriptor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 |
8 | namespace System.CommandLine.NamingConventionBinder;
9 |
10 | ///
11 | /// Provides information for binding command line input to a constructor.
12 | ///
13 | public class ConstructorDescriptor : IMethodDescriptor
14 | {
15 | private List? _parameterDescriptors;
16 |
17 | private readonly ConstructorInfo _constructorInfo;
18 |
19 | internal ConstructorDescriptor(
20 | ConstructorInfo constructorInfo,
21 | ModelDescriptor parent)
22 | {
23 | Parent = parent;
24 | _constructorInfo = constructorInfo;
25 | }
26 |
27 | ///
28 | public ModelDescriptor Parent { get; }
29 |
30 | ///
31 | public IReadOnlyList ParameterDescriptors =>
32 | _parameterDescriptors ??=
33 | _constructorInfo.GetParameters().Select(p => new ParameterDescriptor(p, this)).ToList();
34 |
35 | internal object Invoke(IReadOnlyCollection