├── .config └── tsaoptions.json ├── .editorconfig ├── .gitignore ├── .packages ├── Directory.Build.props ├── Directory.Build.targets └── Directory.Packages.props ├── CODE-OF-CONDUCT.md ├── Directory.Build.props ├── Directory.Build.targets ├── Directory.Packages.props ├── LICENSE.TXT ├── NuGet.config ├── README.md ├── SECURITY.md ├── artifacts ├── Directory.Build.props ├── Directory.Build.targets └── Directory.Packages.props ├── azure-pipeline-codeql.yml ├── azure-pipelines-pr.yml ├── azure-pipelines.yml ├── dnceng-shared.sln ├── eng ├── PoliCheckExclusions.xml ├── Publishing.props ├── Version.Details.xml ├── Versions.props ├── common │ ├── BuildConfiguration │ │ └── build-configuration.json │ ├── CIBuild.cmd │ ├── PSScriptAnalyzerSettings.psd1 │ ├── README.md │ ├── SetupNugetSources.ps1 │ ├── SetupNugetSources.sh │ ├── build.ps1 │ ├── build.sh │ ├── cibuild.sh │ ├── cross │ │ ├── arm │ │ │ ├── sources.list.bionic │ │ │ ├── sources.list.focal │ │ │ ├── sources.list.jammy │ │ │ ├── sources.list.jessie │ │ │ ├── sources.list.xenial │ │ │ ├── sources.list.zesty │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── arm64 │ │ │ ├── sources.list.bionic │ │ │ ├── sources.list.buster │ │ │ ├── sources.list.focal │ │ │ ├── sources.list.jammy │ │ │ ├── sources.list.stretch │ │ │ ├── sources.list.xenial │ │ │ ├── sources.list.zesty │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── armel │ │ │ ├── armel.jessie.patch │ │ │ ├── sources.list.jessie │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── armv6 │ │ │ └── sources.list.buster │ │ ├── build-android-rootfs.sh │ │ ├── build-rootfs.sh │ │ ├── ppc64le │ │ │ └── sources.list.bionic │ │ ├── riscv64 │ │ │ └── sources.list.sid │ │ ├── s390x │ │ │ └── sources.list.bionic │ │ ├── tizen-build-rootfs.sh │ │ ├── tizen-fetch.sh │ │ └── toolchain.cmake │ ├── 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 │ │ ├── add-build-to-channel.ps1 │ │ ├── check-channel-consistency.ps1 │ │ ├── nuget-validation.ps1 │ │ ├── post-build-utils.ps1 │ │ ├── publish-using-darc.ps1 │ │ ├── sourcelink-validation.ps1 │ │ ├── symbols-validation.ps1 │ │ └── trigger-subscriptions.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 │ ├── 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 │ │ │ └── trigger-subscription.yml │ │ ├── steps │ │ │ ├── add-build-to-channel.yml │ │ │ ├── build-reason.yml │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── execute-codeql.yml │ │ │ ├── execute-sdl.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-logs.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ └── source-build.yml │ │ └── variables │ │ │ ├── pool-providers.yml │ │ │ └── sdl-variables.yml │ ├── templates │ │ ├── job │ │ │ ├── execute-sdl.yml │ │ │ ├── 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 │ │ │ └── trigger-subscription.yml │ │ ├── steps │ │ │ ├── add-build-to-channel.yml │ │ │ ├── build-reason.yml │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── execute-codeql.yml │ │ │ ├── execute-sdl.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-logs.yml │ │ │ ├── retain-build.yml │ │ │ ├── run-on-unix.yml │ │ │ ├── run-on-windows.yml │ │ │ ├── run-script-ifequalelse.yml │ │ │ ├── send-to-helix.yml │ │ │ ├── source-build.yml │ │ │ ├── telemetry-end.yml │ │ │ └── telemetry-start.yml │ │ └── variables │ │ │ ├── pool-providers.yml │ │ │ └── sdl-variables.yml │ ├── tools.ps1 │ └── tools.sh ├── helpers.psm1 ├── set-version-parameters.ps1 └── test.yaml ├── global.json ├── src ├── CoreHealthMonitor │ ├── CoreHealthMonitor.cs │ ├── CoreHealthMonitor.csproj │ └── DriveMonitorOptions.cs ├── MIcrosoft.DotNet.Internal.Logging │ ├── FormattableStringFormatter.cs │ ├── Microsoft.DotNet.Internal.Logging.csproj │ ├── Operation.cs │ ├── OperationManager.cs │ ├── OperationManagerOptions.cs │ └── ServiceCollectionExtensions.cs ├── Microsoft.AspNetCore.ApiPagination │ ├── ApiPaginationApplicationModelConvention.cs │ ├── ApiPaginationMvcBuilderExtensions.cs │ ├── Microsoft.AspNetCore.ApiPagination.csproj │ ├── ObjectExtensions.cs │ └── PaginatedAttribute.cs ├── Microsoft.AspNetCore.ApiVersioning.Analyzers │ ├── DoNotUseUnversionedTypesInVersionedApis.cs │ ├── Helpers.cs │ ├── KnownTypes.cs │ ├── Microsoft.AspNetCore.ApiVersioning.Analyzers.csproj │ └── TypeVersionChecker.cs ├── Microsoft.AspNetCore.ApiVersioning.Swashbuckle │ ├── ConfigureSwaggerVersions.cs │ ├── HeaderVersioningOperationFilter.cs │ ├── ISwaggerVersioningScheme.cs │ ├── Microsoft.AspNetCore.ApiVersioning.Swashbuckle.csproj │ ├── QueryVersioningOperationFilter.cs │ ├── SwaggerApiResponseAttribute.cs │ ├── SwaggerApiVersioningExtensions.cs │ ├── SwaggerModelBindingOperationFilter.cs │ └── VersioningOperationFilter.cs ├── Microsoft.AspNetCore.ApiVersioning │ ├── ApiRemovedAttribute.cs │ ├── ApiVersioningExtensions.cs │ ├── ApiVersioningOptions.cs │ ├── ApiVersioningOptionsExtensions.cs │ ├── IVersioningScheme.cs │ ├── Microsoft.AspNetCore.ApiVersioning.csproj │ ├── RequiredParameterDescriptorProvider.cs │ ├── Schemes │ │ ├── HeaderVersioningScheme.cs │ │ ├── PathVersioningScheme.cs │ │ └── QueryVersioningScheme.cs │ ├── SetRequiredModelMetadata.cs │ ├── SuppressVersionErrorsAttribute.cs │ ├── VersionedApiConvention.cs │ └── VersionedControllerProvider.cs ├── Microsoft.DncEng.CommandLineLib │ ├── Authentication │ │ ├── InteractiveTokenCredentialProvider.cs │ │ └── TokenCredentialProvider.cs │ ├── Command.cs │ ├── CommandAttribute.cs │ ├── CommandOptions.cs │ ├── ConsoleExtensions.cs │ ├── DefaultCommandRegistry.cs │ ├── DefaultConsole.cs │ ├── DefaultConsoleBackend.cs │ ├── DependencyInjectedConsoleApp.cs │ ├── ExitCodes.cs │ ├── FailWithExitCodeException.cs │ ├── GlobalCommand.cs │ ├── ICommandOptions.cs │ ├── ICommandRegistry.cs │ ├── IConsole.cs │ ├── IConsoleBackend.cs │ ├── ISystemClock.cs │ ├── Microsoft.DncEng.CommandLineLib.csproj │ ├── SystemClock.cs │ └── VerbosityLevel.cs ├── Microsoft.DncEng.Configuration.Extensions │ ├── AppConfigurationConfigMapper.cs │ ├── ConfigMapper.cs │ ├── ConfigurationConstants.cs │ ├── KeyVaultConfigMapper.cs │ ├── LocalDevTokenCredential.cs │ ├── MappedJsonConfigurationProvider.cs │ ├── MappedJsonConfigurationSource.cs │ ├── Microsoft.DncEng.Configuration.Extensions.csproj │ ├── RegexConfigMapper.cs │ ├── SentinelFileLock.cs │ └── ServiceConfigurationExtensions.cs ├── Microsoft.DotNet.Authentication.Algorithms │ ├── Microsoft.DotNet.Authentication.Algorithms.csproj │ └── OneTimePasswordGenerator.cs ├── Microsoft.DotNet.GitHub.Authentication │ ├── GitHubAppTokenProvider.cs │ ├── GitHubApplicationClientFactory.cs │ ├── GitHubClientFactory.cs │ ├── GitHubClientOptions.cs │ ├── GitHubHelper.cs │ ├── GitHubTokenProvider.cs │ ├── GitHubTokenProviderOptions.cs │ ├── IGitHubAppTokenProvider.cs │ ├── IGitHubApplicationClientFactory.cs │ ├── IGitHubClientFactory.cs │ ├── IGitHubTokenProvider.cs │ ├── InMemoryCacheInstallationLookup.cs │ ├── InstallationLookup.cs │ ├── Microsoft.DotNet.GitHub.Authentication.csproj │ └── ServiceCollectionExtensions.cs ├── Microsoft.DotNet.Internal.AkaMsLinks │ ├── AkaMsLinksManager.cs │ ├── Microsoft.DotNet.Internal.AkaMsLinks.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Microsoft.DotNet.Internal.DependencyInjection.Testing │ ├── DependencyInjectionValidation.cs │ └── Microsoft.DotNet.Internal.DependencyInjection.Testing.csproj ├── Microsoft.DotNet.Internal.DependencyInjection │ ├── ClientFactory.cs │ ├── ClientFactoryExtensions.cs │ ├── IClientFactory.cs │ ├── Microsoft.DotNet.Internal.DependencyInjection.csproj │ ├── RefCountedObject.cs │ ├── ResolvingLazy.cs │ ├── ServiceCollectionExtensions.cs │ └── SingleClientFactory.cs ├── Microsoft.DotNet.Internal.Health │ ├── AzureTableHealthReportProvider.cs │ ├── AzureTableHealthReportingOptions.cs │ ├── HealthReport.cs │ ├── HealthReportExtensions.cs │ ├── HealthReportTableEntity.cs │ ├── HealthReporterFactory.cs │ ├── HealthReportingBuilder.cs │ ├── HealthStatus.cs │ ├── IExternalHealthReporter.cs │ ├── IHealthReportProvider.cs │ ├── IHealthReporter.cs │ ├── IHealthReporterFactory.cs │ ├── IInstanceAccessor.cs │ ├── IInstanceHealthReporter.cs │ ├── IServiceHealthReporter.cs │ ├── InstanceAccessor.cs │ ├── LogHealthReporter.cs │ ├── MachineNameInstanceAccessor.cs │ ├── Microsoft.DotNet.Internal.Health.csproj │ ├── ServiceFabricHealthReportProvider.cs │ └── ServiceFabricInstanceAccessor.cs ├── Microsoft.DotNet.Internal.SymbolHelper │ ├── Microsoft.DotNet.Internal.SymbolHelper.csproj │ ├── ScopedTracer.cs │ ├── SymbolPromotionHelper.cs │ ├── SymbolPublisherOptions.cs │ ├── SymbolRequestHelpers.cs │ ├── SymbolUploadHelper.cs │ └── SymbolUploadHelperFactory.cs ├── Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions │ ├── ConfigureAllParametersAttribute.cs │ ├── Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions.csproj │ ├── TestDependencyInjectionSetupAttribute.cs │ └── readme.md ├── Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen │ ├── ConfigMethod.cs │ ├── ConfigParameters.cs │ ├── Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.csproj │ ├── SymbolNameHelper.cs │ ├── TestConfigDeclaration.cs │ ├── TestDataClassWriter.cs │ ├── TestDataGenerator.cs │ └── TestDataReceiver.cs ├── Microsoft.DotNet.Internal.Testing.Utility │ ├── CountingLogger.cs │ ├── Microsoft.DotNet.Internal.Testing.Utility.csproj │ ├── MockHttpClientFactory.cs │ ├── NUnitLogger.cs │ ├── StringRegexAssertionExtensions.cs │ ├── TestAppFactory.cs │ └── TestClock.cs ├── Microsoft.DotNet.Kusto │ ├── CsvWriterExtensions.cs │ ├── IKustoClientProvider.cs │ ├── KustoClientProvider.cs │ ├── KustoDataType.cs │ ├── KustoHelpers.cs │ ├── KustoOptions.cs │ ├── KustoParameter.cs │ ├── KustoQuery.cs │ ├── KustoServiceCollectionExtensions.cs │ ├── KustoValue.cs │ └── Microsoft.DotNet.Kusto.csproj ├── Microsoft.DotNet.Metrics │ ├── ApplicationInsightsMetricTracker.cs │ ├── IMetricTracker.cs │ └── Microsoft.DotNet.Metrics.csproj ├── Microsoft.DotNet.ServiceFabric.ServiceHost │ ├── Actors │ │ ├── DelegatedActor.cs │ │ └── IActorImplementation.cs │ ├── AppInsightsFlushLifecycle.cs │ ├── DelegatedService.cs │ ├── DelegatedStatefulService.cs │ ├── DelegatedStatelessService.cs │ ├── DelegatedStatelessWebService.cs │ ├── Extensions.cs │ ├── IServiceImplementation.cs │ ├── Lifecycle.cs │ ├── LoadReporting │ │ ├── EmptyServiceLoadReporter.cs │ │ ├── IServiceLoadReporter.cs │ │ ├── StatefulServiceLoadReporter.cs │ │ └── StatelessServiceLoadReporter.cs │ ├── LoggedServiceRemoting │ │ ├── ActivityServiceRemotingClient.cs │ │ ├── ActivityServiceRemotingClientFactory.cs │ │ ├── ActivityServiceRemotingMessageDispatcher.cs │ │ ├── AsyncInterceptor.cs │ │ ├── InvokeInNewScopeInterceptor.cs │ │ ├── LoggingServiceInterceptor.cs │ │ ├── LoggingServiceProxyInterceptor.cs │ │ ├── ServiceHostActorProxy.cs │ │ ├── ServiceHostProxy.cs │ │ └── ServiceHostRemoting.cs │ ├── Microsoft.DotNet.ServiceFabric.ServiceHost.csproj │ ├── Microsoft.DotNet.ServiceFabric.ServiceHost.csproj.DotSettings │ ├── RichExceptionTelemetryInitializer.cs │ ├── ScheduledService │ │ ├── CronScheduleAttribute.cs │ │ ├── FuncInvokingJob.cs │ │ ├── ScheduledService.cs │ │ └── TimeZones.cs │ ├── ServiceFabricHelpers.cs │ ├── ServiceFabricLookup.cs │ ├── ServiceFabricServiceCollectionExtensions.cs │ ├── ServiceHost.AI.cs │ ├── ServiceHost.cs │ ├── ServiceHostEventListener.cs │ ├── ServiceHostWebSite.cs │ └── TemporaryFiles.cs ├── Microsoft.DotNet.Services.Utility │ ├── AzureDevOpsDelegatingHandler.cs │ ├── AzureStorageTableEntities.cs │ ├── DefaultHttpHandlerConfiguration.cs │ ├── DefaultHttpHandlerConfigurationExtensions.cs │ ├── ExponentialRetry.cs │ ├── GitHelpers.cs │ ├── Microsoft.DotNet.Services.Utility.csproj │ ├── RetryAfterHandler.cs │ ├── RetryAllHandler.cs │ └── obj │ │ ├── Microsoft.DotNet.Services.Utility.csproj.nuget.dgspec.json │ │ ├── Microsoft.DotNet.Services.Utility.csproj.nuget.g.props │ │ ├── Microsoft.DotNet.Services.Utility.csproj.nuget.g.targets │ │ ├── project.assets.json │ │ └── project.nuget.cache ├── Microsoft.DotNet.Web.Authentication │ ├── AccessToken │ │ ├── GetTokenHashContext.cs │ │ ├── PersonalAccessTokenAuthenticationExtensions.cs │ │ ├── PersonalAccessTokenAuthenticationHandler.cs │ │ ├── PersonalAccessTokenAuthenticationOptions.cs │ │ ├── PersonalAccessTokenDefaults.cs │ │ ├── PersonalAccessTokenEvents.cs │ │ ├── PersonalAccessTokenValidatePrincipalContext.cs │ │ └── SetTokenHashContext.cs │ ├── DefaultAuthorizeActionModelConvention.cs │ ├── GitHub │ │ ├── GitHubAuthenticationExtensions.cs │ │ ├── GitHubAuthenticationHandler.cs │ │ ├── GitHubAuthenticationOptions.cs │ │ └── GitHubClaimResolver.cs │ ├── Microsoft.DotNet.Web.Authentication.csproj │ └── SimpleSigninMiddleware.cs └── ServiceFabricMocks │ ├── MockActorStateManager.cs │ ├── MockReliableDictionary.cs │ ├── MockReliableQueue.cs │ ├── MockReliableStateManager.cs │ ├── MockTransaction.cs │ ├── ServiceFabricMocks.csproj │ └── SyncAsyncEnumerable.cs └── test ├── CoreHealthMonitor.Tests ├── CoreHealthMonitor.Tests.csproj └── DependencyRegistrationTests.cs ├── Microsoft.DotNet.Authentication.Algorithms.Tests ├── Microsoft.DotNet.Authentication.Algorithms.Tests.csproj └── OneTimePasswordGeneratorTests.cs ├── Microsoft.DotNet.GitHub.Authentication.Tests ├── GitHubAppTokenProviderTests.cs └── Microsoft.DotNet.GitHub.Authentication.Tests.csproj ├── Microsoft.DotNet.Internal.AkaMsLinks.Test ├── AkaMsLinksTests.cs └── Microsoft.DotNet.Internal.AkaMsLinks.Tests.csproj ├── Microsoft.DotNet.Internal.DependencyInjection.Testing.Tests ├── Dependencies.cs ├── DependencyInjectionTestValidation.cs └── Microsoft.DotNet.Internal.DependencyInjection.Testing.Tests.csproj ├── Microsoft.DotNet.Internal.DependencyInjection.Tests ├── ClientFactoryTests.cs ├── LazyTests.cs └── Microsoft.DotNet.Internal.DependencyInjection.Tests.csproj ├── Microsoft.DotNet.Internal.Health.Tests ├── AzureTableHealthReportProviderTests.cs ├── HealthReporterFactoryTests.cs ├── Microsoft.DotNet.Internal.Health.Tests.csproj └── MockHandler.cs ├── Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests ├── ArrayTests.cs ├── AsyncConfigurationTest.cs ├── DisposeCalledTest.cs ├── Injectable.cs ├── Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests.csproj ├── MultipleRegistrations.cs ├── NoConfigTest.cs ├── NoParameterValueTest.cs ├── ParameterTests.cs ├── Ref.cs ├── SyncConfigTests.cs ├── TupleTest.cs └── WithParameterValueTest.cs ├── Microsoft.DotNet.Kusto.Tests ├── CsvWriterTests.cs ├── KustoClientProviderTests.cs ├── KustoHelpersTests.cs ├── Microsoft.DotNet.Kusto.Tests.csproj └── MockOptionMonitor.cs ├── Microsoft.DotNet.ServiceFabric.ServiceHost.Tests ├── AsyncInterceptorTests.cs ├── DelegatedServiceTest.cs ├── DelegatedStatelessWebServiceStartupTests.cs ├── ExtensionsTests.cs ├── FakeChannel.cs ├── IFakeService.cs ├── InvokeInNewScopeInterceptorTests.cs ├── LoggingServiceInterceptorTests.cs ├── LoggingServiceProxyInterceptorTests.cs ├── Microsoft.DotNet.ServiceFabric.ServiceHost.Tests.csproj ├── MockBuilder.cs ├── ServiceHostTests.cs └── TemporaryFilesTest.cs └── Microsoft.DotNet.Web.Authentication.Tests ├── Controllers ├── AnonymousAttributeController.cs ├── AnyAttributeController.cs ├── NoAttributeController.cs └── RoleAttributeController.cs ├── DefaultAuthorizeActionModelConventionTests.cs ├── DefaultHttpContextExtensions.cs ├── EmptyTestStartup.cs ├── GitHubClaimsResolverTests.cs ├── Microsoft.DotNet.Web.Authentication.Tests.csproj ├── PersonalAccessTokenAuthenticationTests.cs └── SimpleSigninTests.cs /.config/tsaoptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "instanceUrl": "https://devdiv.visualstudio.com/", 3 | "template": "TFSDEVDIV", 4 | "projectName": "DEVDIV", 5 | "areaPath": "DevDiv\\NET Fundamentals\\Infrastructure\\Arcade\\SDL", 6 | "iterationPath": "DevDiv", 7 | "notificationAliases": [ "dnceng@microsoft.com" ], 8 | "repositoryName":"dotnet-dnceng-shared", 9 | "codebaseName": "dotnet-dnceng-shared" 10 | } -------------------------------------------------------------------------------- /.packages/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.packages/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.packages/Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /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). -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository has shared libraries and services used by the .NET engineering services team. -------------------------------------------------------------------------------- /artifacts/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /artifacts/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /artifacts/Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /eng/PoliCheckExclusions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SWAGGER 5 | -------------------------------------------------------------------------------- /eng/Publishing.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 3 5 | 6 | -------------------------------------------------------------------------------- /eng/Version.Details.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | https://github.com/dotnet/arcade 8 | 4246a31e5de9de87f760218c4f588cebf4661f45 9 | 10 | 11 | https://github.com/dotnet/arcade 12 | 4246a31e5de9de87f760218c4f588cebf4661f45 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /eng/Versions.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0.0.99 6 | beta 7 | 8 | false 9 | true 10 | 1.0.0-preview.1 11 | 12 | 8.0.0-beta.25230.1 13 | 17.4.1 14 | 15 | 16 | 17 | Microsoft.DotNet.Build.Tasks.Feed 18 | 19 | 20 | -------------------------------------------------------------------------------- /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/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/cross/arm/sources.list.bionic: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm/sources.list.focal: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm/sources.list.jammy: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm/sources.list.jessie: -------------------------------------------------------------------------------- 1 | # Debian (sid) # UNSTABLE 2 | deb http://ftp.debian.org/debian/ sid main contrib non-free 3 | deb-src http://ftp.debian.org/debian/ sid main contrib non-free 4 | -------------------------------------------------------------------------------- /eng/common/cross/arm/sources.list.xenial: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm/sources.list.zesty: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /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/sources.list.bionic: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/sources.list.buster: -------------------------------------------------------------------------------- 1 | deb http://deb.debian.org/debian buster main 2 | deb-src http://deb.debian.org/debian buster main 3 | 4 | deb http://deb.debian.org/debian-security/ buster/updates main 5 | deb-src http://deb.debian.org/debian-security/ buster/updates main 6 | 7 | deb http://deb.debian.org/debian buster-updates main 8 | deb-src http://deb.debian.org/debian buster-updates main 9 | 10 | deb http://deb.debian.org/debian buster-backports main contrib non-free 11 | deb-src http://deb.debian.org/debian buster-backports main contrib non-free 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/sources.list.focal: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/sources.list.jammy: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/sources.list.stretch: -------------------------------------------------------------------------------- 1 | deb http://deb.debian.org/debian stretch main 2 | deb-src http://deb.debian.org/debian stretch main 3 | 4 | deb http://deb.debian.org/debian-security/ stretch/updates main 5 | deb-src http://deb.debian.org/debian-security/ stretch/updates main 6 | 7 | deb http://deb.debian.org/debian stretch-updates main 8 | deb-src http://deb.debian.org/debian stretch-updates main 9 | 10 | deb http://deb.debian.org/debian stretch-backports main contrib non-free 11 | deb-src http://deb.debian.org/debian stretch-backports main contrib non-free 12 | 13 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/sources.list.xenial: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/sources.list.zesty: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /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/sources.list.jessie: -------------------------------------------------------------------------------- 1 | # Debian (jessie) # Stable 2 | deb http://ftp.debian.org/debian/ jessie main contrib non-free 3 | deb-src http://ftp.debian.org/debian/ jessie main contrib non-free 4 | -------------------------------------------------------------------------------- /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/armv6/sources.list.buster: -------------------------------------------------------------------------------- 1 | deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi 2 | deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi 3 | -------------------------------------------------------------------------------- /eng/common/cross/ppc64le/sources.list.bionic: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/riscv64/sources.list.sid: -------------------------------------------------------------------------------- 1 | deb http://deb.debian.org/debian-ports sid main 2 | -------------------------------------------------------------------------------- /eng/common/cross/s390x/sources.list.bionic: -------------------------------------------------------------------------------- 1 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 2 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe 3 | 4 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 5 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe 6 | 7 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 8 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted 9 | 10 | deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 11 | deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /eng/common/cross/tizen-build-rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | ARCH=$1 5 | LINK_ARCH=$ARCH 6 | 7 | case "$ARCH" in 8 | arm) 9 | TIZEN_ARCH="armv7hl" 10 | ;; 11 | armel) 12 | TIZEN_ARCH="armv7l" 13 | LINK_ARCH="arm" 14 | ;; 15 | arm64) 16 | TIZEN_ARCH="aarch64" 17 | ;; 18 | x86) 19 | TIZEN_ARCH="i686" 20 | ;; 21 | x64) 22 | TIZEN_ARCH="x86_64" 23 | LINK_ARCH="x86" 24 | ;; 25 | *) 26 | echo "Unsupported architecture for tizen: $ARCH" 27 | exit 1 28 | esac 29 | 30 | __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 31 | __TIZEN_CROSSDIR="$__CrossDir/${ARCH}/tizen" 32 | 33 | if [[ -z "$ROOTFS_DIR" ]]; then 34 | echo "ROOTFS_DIR is not defined." 35 | exit 1; 36 | fi 37 | 38 | TIZEN_TMP_DIR=$ROOTFS_DIR/tizen_tmp 39 | mkdir -p $TIZEN_TMP_DIR 40 | 41 | # Download files 42 | echo ">>Start downloading files" 43 | VERBOSE=1 $__CrossDir/tizen-fetch.sh $TIZEN_TMP_DIR $TIZEN_ARCH 44 | echo "<>Start constructing Tizen rootfs" 47 | TIZEN_RPM_FILES=`ls $TIZEN_TMP_DIR/*.rpm` 48 | cd $ROOTFS_DIR 49 | for f in $TIZEN_RPM_FILES; do 50 | rpm2cpio $f | cpio -idm --quiet 51 | done 52 | echo "<>Start configuring Tizen rootfs" 59 | ln -sfn asm-${LINK_ARCH} ./usr/include/asm 60 | patch -p1 < $__TIZEN_CROSSDIR/tizen.patch 61 | echo "<\\|?@*"() ]', '_' 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 | msbuild 5 | 6 | 7 | 8 | 9 | %(Identity) 10 | 11 | 12 | 13 | 14 | 15 | $(WorkItemDirectory) 16 | $(WorkItemCommand) 17 | $(WorkItemTimeout) 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | [Parameter(Mandatory=$true)][string] $ToolDestinationPath # Where the validation tool should be downloaded to 7 | ) 8 | 9 | try { 10 | . $PSScriptRoot\post-build-utils.ps1 11 | 12 | $url = 'https://raw.githubusercontent.com/NuGet/NuGetGallery/3e25ad135146676bcab0050a516939d9958bfa5d/src/VerifyMicrosoftPackage/verify.ps1' 13 | 14 | New-Item -ItemType 'directory' -Path ${ToolDestinationPath} -Force 15 | 16 | Invoke-WebRequest $url -OutFile ${ToolDestinationPath}\verify.ps1 17 | 18 | & ${ToolDestinationPath}\verify.ps1 ${PackagesPath}\*.nupkg 19 | } 20 | catch { 21 | Write-Host $_.ScriptStackTrace 22 | Write-PipelineTelemetryError -Category 'NuGetValidation' -Message $_ 23 | ExitWithExitCode 1 24 | } 25 | -------------------------------------------------------------------------------- /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 | [string]$Source = "https://pkgs.dev.azure.com/dnceng/_packaging/Guardian1ESPTUpstreamOrgFeed/nuget/v3/index.json", 8 | 9 | # If omitted, install the latest version of Guardian, otherwise install that specific version. 10 | [string]$Version 11 | ) 12 | 13 | $ErrorActionPreference = 'Stop' 14 | Set-StrictMode -Version 2.0 15 | $disableConfigureToolsetImport = $true 16 | $global:LASTEXITCODE = 0 17 | 18 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 19 | # scripts don't necessarily execute in the same agent that run the 20 | # build.ps1/sh script this variable isn't automatically set. 21 | $ci = $true 22 | . $PSScriptRoot\..\tools.ps1 23 | 24 | $argumentList = @("install", "Microsoft.Guardian.Cli.win-x64", "-Source $Source", "-OutputDirectory $Path", "-NonInteractive", "-NoCache") 25 | 26 | if ($Version) { 27 | $argumentList += "-Version $Version" 28 | } 29 | 30 | Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait 31 | 32 | $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path 33 | 34 | if (!$gdnCliPath) 35 | { 36 | Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian' 37 | } 38 | 39 | return $gdnCliPath.FullName 40 | } -------------------------------------------------------------------------------- /eng/common/templates-official/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 | 9 | jobs: 10 | - template: /eng/common/templates-official/jobs/jobs.yml 11 | parameters: 12 | enableMicrobuild: false 13 | enablePublishBuildArtifacts: false 14 | enablePublishTestResults: false 15 | enablePublishBuildAssets: false 16 | enablePublishUsingPipelines: false 17 | enableTelemetry: true 18 | 19 | variables: 20 | - group: Publish-Build-Assets 21 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in 22 | # sync with the packages.config file. 23 | - name: DefaultGuardianVersion 24 | value: 0.109.0 25 | - name: GuardianPackagesConfigFile 26 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config 27 | - name: GuardianVersion 28 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }} 29 | 30 | jobs: ${{ parameters.jobs }} 31 | 32 | -------------------------------------------------------------------------------- /eng/common/templates-official/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: MaestroApiAccessToken 12 | value: $(MaestroAccessToken) 13 | - name: MaestroApiVersion 14 | value: "2020-02-20" 15 | 16 | - name: SourceLinkCLIVersion 17 | value: 3.0.0 18 | - name: SymbolToolVersion 19 | value: 1.0.1 20 | 21 | - name: runCodesignValidationInjection 22 | value: false 23 | -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/trigger-subscription.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | ChannelId: 0 3 | 4 | steps: 5 | - task: PowerShell@2 6 | displayName: Triggering subscriptions 7 | inputs: 8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/trigger-subscriptions.ps1 9 | arguments: -SourceRepo $(Build.Repository.Uri) 10 | -ChannelId ${{ parameters.ChannelId }} 11 | -MaestroApiAccessToken $(MaestroAccessToken) 12 | -MaestroApiEndPoint $(MaestroApiEndPoint) 13 | -MaestroApiVersion $(MaestroApiVersion) 14 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/add-build-to-channel.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | ChannelId: 0 3 | 4 | steps: 5 | - task: PowerShell@2 6 | displayName: Add Build to Channel 7 | inputs: 8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/add-build-to-channel.ps1 9 | arguments: -BuildId $(BARBuildId) 10 | -ChannelId ${{ parameters.ChannelId }} 11 | -MaestroApiAccessToken $(MaestroApiAccessToken) 12 | -MaestroApiEndPoint $(MaestroApiEndPoint) 13 | -MaestroApiVersion $(MaestroApiVersion) 14 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/build-reason.yml: -------------------------------------------------------------------------------- 1 | # build-reason.yml 2 | # Description: runs steps if build.reason condition is valid. conditions is a string of valid build reasons 3 | # to include steps (',' separated). 4 | parameters: 5 | conditions: '' 6 | steps: [] 7 | 8 | steps: 9 | - ${{ if and( not(startsWith(parameters.conditions, 'not')), contains(parameters.conditions, variables['build.reason'])) }}: 10 | - ${{ parameters.steps }} 11 | - ${{ if and( startsWith(parameters.conditions, 'not'), not(contains(parameters.conditions, variables['build.reason']))) }}: 12 | - ${{ parameters.steps }} 13 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | disableComponentGovernance: false 3 | componentGovernanceIgnoreDirectories: '' 4 | 5 | steps: 6 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}: 7 | - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true" 8 | displayName: Set skipComponentGovernanceDetection variable 9 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}: 10 | - task: ComponentGovernanceComponentDetection@0 11 | continueOnError: true 12 | inputs: 13 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} -------------------------------------------------------------------------------- /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 | 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 | 18 | steps: 19 | - ${{ if ne(variables['System.TeamProject'], 'public') }}: 20 | - template: /eng/common/templates-official/steps/get-delegation-sas.yml 21 | parameters: 22 | federatedServiceConnection: ${{ parameters.federatedServiceConnection }} 23 | outputVariableName: ${{ parameters.outputVariableName }} 24 | expiryInHours: ${{ parameters.expiryInHours }} 25 | base64Encode: ${{ parameters.base64Encode }} 26 | storageAccount: dotnetbuilds 27 | container: internal 28 | permissions: rl 29 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: federatedServiceConnection 3 | type: string 4 | - name: outputVariableName 5 | type: string 6 | - name: stepName 7 | type: string 8 | default: 'getFederatedAccessToken' 9 | - name: condition 10 | type: string 11 | default: '' 12 | # Resource to get a token for. Common values include: 13 | # - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps 14 | # - 'https://storage.azure.com/' for storage 15 | # Defaults to Azure DevOps 16 | - name: resource 17 | type: string 18 | default: '499b84ac-1321-427f-aa17-267ca6975798' 19 | - name: isStepOutputVariable 20 | type: boolean 21 | default: false 22 | 23 | steps: 24 | - task: AzureCLI@2 25 | displayName: 'Getting federated access token for feeds' 26 | name: ${{ parameters.stepName }} 27 | ${{ if ne(parameters.condition, '') }}: 28 | condition: ${{ parameters.condition }} 29 | inputs: 30 | azureSubscription: ${{ parameters.federatedServiceConnection }} 31 | scriptType: 'pscore' 32 | scriptLocation: 'inlineScript' 33 | inlineScript: | 34 | $accessToken = az account get-access-token --query accessToken --resource ${{ parameters.resource }} --output tsv 35 | if ($LASTEXITCODE -ne 0) { 36 | Write-Error "Failed to get access token for resource '${{ parameters.resource }}'" 37 | exit 1 38 | } 39 | Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value" 40 | Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true;isOutput=${{ parameters.isStepOutputVariable }}]$accessToken" -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | StageLabel: '' 3 | JobLabel: '' 4 | 5 | steps: 6 | - task: Powershell@2 7 | displayName: Prepare Binlogs to Upload 8 | inputs: 9 | targetType: inline 10 | script: | 11 | New-Item -ItemType Directory $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ 12 | Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ 13 | continueOnError: true 14 | condition: always() 15 | 16 | - task: 1ES.PublishBuildArtifacts@1 17 | displayName: Publish Logs 18 | inputs: 19 | PathtoPublish: '$(Build.SourcesDirectory)/PostBuildLogs' 20 | PublishLocation: Container 21 | ArtifactName: PostBuildLogs 22 | continueOnError: true 23 | condition: always() 24 | -------------------------------------------------------------------------------- /eng/common/templates-official/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/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/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 | 9 | jobs: 10 | - template: /eng/common/templates/jobs/jobs.yml 11 | parameters: 12 | enableMicrobuild: false 13 | enablePublishBuildArtifacts: false 14 | enablePublishTestResults: false 15 | enablePublishBuildAssets: false 16 | enablePublishUsingPipelines: false 17 | enableTelemetry: true 18 | 19 | variables: 20 | - group: Publish-Build-Assets 21 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in 22 | # sync with the packages.config file. 23 | - name: DefaultGuardianVersion 24 | value: 0.109.0 25 | - name: GuardianPackagesConfigFile 26 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config 27 | - name: GuardianVersion 28 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }} 29 | 30 | jobs: ${{ parameters.jobs }} 31 | 32 | -------------------------------------------------------------------------------- /eng/common/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: MaestroApiAccessToken 12 | value: $(MaestroAccessToken) 13 | - name: MaestroApiVersion 14 | value: "2020-02-20" 15 | 16 | - name: SourceLinkCLIVersion 17 | value: 3.0.0 18 | - name: SymbolToolVersion 19 | value: 1.0.1 20 | 21 | - name: runCodesignValidationInjection 22 | value: false 23 | -------------------------------------------------------------------------------- /eng/common/templates/post-build/trigger-subscription.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | ChannelId: 0 3 | 4 | steps: 5 | - task: PowerShell@2 6 | displayName: Triggering subscriptions 7 | inputs: 8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/trigger-subscriptions.ps1 9 | arguments: -SourceRepo $(Build.Repository.Uri) 10 | -ChannelId ${{ parameters.ChannelId }} 11 | -MaestroApiAccessToken $(MaestroAccessToken) 12 | -MaestroApiEndPoint $(MaestroApiEndPoint) 13 | -MaestroApiVersion $(MaestroApiVersion) 14 | -------------------------------------------------------------------------------- /eng/common/templates/steps/add-build-to-channel.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | ChannelId: 0 3 | 4 | steps: 5 | - task: PowerShell@2 6 | displayName: Add Build to Channel 7 | inputs: 8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/add-build-to-channel.ps1 9 | arguments: -BuildId $(BARBuildId) 10 | -ChannelId ${{ parameters.ChannelId }} 11 | -MaestroApiAccessToken $(MaestroApiAccessToken) 12 | -MaestroApiEndPoint $(MaestroApiEndPoint) 13 | -MaestroApiVersion $(MaestroApiVersion) 14 | -------------------------------------------------------------------------------- /eng/common/templates/steps/build-reason.yml: -------------------------------------------------------------------------------- 1 | # build-reason.yml 2 | # Description: runs steps if build.reason condition is valid. conditions is a string of valid build reasons 3 | # to include steps (',' separated). 4 | parameters: 5 | conditions: '' 6 | steps: [] 7 | 8 | steps: 9 | - ${{ if and( not(startsWith(parameters.conditions, 'not')), contains(parameters.conditions, variables['build.reason'])) }}: 10 | - ${{ parameters.steps }} 11 | - ${{ if and( startsWith(parameters.conditions, 'not'), not(contains(parameters.conditions, variables['build.reason']))) }}: 12 | - ${{ parameters.steps }} 13 | -------------------------------------------------------------------------------- /eng/common/templates/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | disableComponentGovernance: false 3 | componentGovernanceIgnoreDirectories: '' 4 | 5 | steps: 6 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}: 7 | - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true" 8 | displayName: Set skipComponentGovernanceDetection variable 9 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}: 10 | - task: ComponentGovernanceComponentDetection@0 11 | continueOnError: true 12 | inputs: 13 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} -------------------------------------------------------------------------------- /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 | 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 | 18 | steps: 19 | - ${{ if ne(variables['System.TeamProject'], 'public') }}: 20 | - template: /eng/common/templates/steps/get-delegation-sas.yml 21 | parameters: 22 | federatedServiceConnection: ${{ parameters.federatedServiceConnection }} 23 | outputVariableName: ${{ parameters.outputVariableName }} 24 | expiryInHours: ${{ parameters.expiryInHours }} 25 | base64Encode: ${{ parameters.base64Encode }} 26 | storageAccount: dotnetbuilds 27 | container: internal 28 | permissions: rl 29 | -------------------------------------------------------------------------------- /eng/common/templates/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: federatedServiceConnection 3 | type: string 4 | - name: outputVariableName 5 | type: string 6 | - name: stepName 7 | type: string 8 | default: 'getFederatedAccessToken' 9 | - name: condition 10 | type: string 11 | default: '' 12 | # Resource to get a token for. Common values include: 13 | # - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps 14 | # - 'https://storage.azure.com/' for storage 15 | # Defaults to Azure DevOps 16 | - name: resource 17 | type: string 18 | default: '499b84ac-1321-427f-aa17-267ca6975798' 19 | - name: isStepOutputVariable 20 | type: boolean 21 | default: false 22 | 23 | steps: 24 | - task: AzureCLI@2 25 | displayName: 'Getting federated access token for feeds' 26 | name: ${{ parameters.stepName }} 27 | ${{ if ne(parameters.condition, '') }}: 28 | condition: ${{ parameters.condition }} 29 | inputs: 30 | azureSubscription: ${{ parameters.federatedServiceConnection }} 31 | scriptType: 'pscore' 32 | scriptLocation: 'inlineScript' 33 | inlineScript: | 34 | $accessToken = az account get-access-token --query accessToken --resource ${{ parameters.resource }} --output tsv 35 | if ($LASTEXITCODE -ne 0) { 36 | Write-Error "Failed to get access token for resource '${{ parameters.resource }}'" 37 | exit 1 38 | } 39 | Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value" 40 | Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true;isOutput=${{ parameters.isStepOutputVariable }}]$accessToken" -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | StageLabel: '' 3 | JobLabel: '' 4 | 5 | steps: 6 | - task: Powershell@2 7 | displayName: Prepare Binlogs to Upload 8 | inputs: 9 | targetType: inline 10 | script: | 11 | New-Item -ItemType Directory $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ 12 | Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ 13 | continueOnError: true 14 | condition: always() 15 | 16 | - task: PublishBuildArtifacts@1 17 | displayName: Publish Logs 18 | inputs: 19 | PathtoPublish: '$(Build.SourcesDirectory)/PostBuildLogs' 20 | PublishLocation: Container 21 | ArtifactName: PostBuildLogs 22 | continueOnError: true 23 | condition: always() 24 | -------------------------------------------------------------------------------- /eng/common/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/templates/steps/run-on-unix.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | agentOs: '' 3 | steps: [] 4 | 5 | steps: 6 | - ${{ if ne(parameters.agentOs, 'Windows_NT') }}: 7 | - ${{ parameters.steps }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/run-on-windows.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | agentOs: '' 3 | steps: [] 4 | 5 | steps: 6 | - ${{ if eq(parameters.agentOs, 'Windows_NT') }}: 7 | - ${{ parameters.steps }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/run-script-ifequalelse.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # if parameter1 equals parameter 2, run 'ifScript' command, else run 'elsescript' command 3 | parameter1: '' 4 | parameter2: '' 5 | ifScript: '' 6 | elseScript: '' 7 | 8 | # name of script step 9 | name: Script 10 | 11 | # display name of script step 12 | displayName: If-Equal-Else Script 13 | 14 | # environment 15 | env: {} 16 | 17 | # conditional expression for step execution 18 | condition: '' 19 | 20 | steps: 21 | - ${{ if and(ne(parameters.ifScript, ''), eq(parameters.parameter1, parameters.parameter2)) }}: 22 | - script: ${{ parameters.ifScript }} 23 | name: ${{ parameters.name }} 24 | displayName: ${{ parameters.displayName }} 25 | env: ${{ parameters.env }} 26 | condition: ${{ parameters.condition }} 27 | 28 | - ${{ if and(ne(parameters.elseScript, ''), ne(parameters.parameter1, parameters.parameter2)) }}: 29 | - script: ${{ parameters.elseScript }} 30 | name: ${{ parameters.name }} 31 | displayName: ${{ parameters.displayName }} 32 | env: ${{ parameters.env }} 33 | condition: ${{ parameters.condition }} -------------------------------------------------------------------------------- /eng/common/templates/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/helpers.psm1: -------------------------------------------------------------------------------- 1 | ############################## 2 | #.SYNOPSIS 3 | # Wrapper for git.exe that handles errors and warnings the powershell way 4 | # 5 | ############################## 6 | function git 7 | { 8 | [cmdletbinding()] 9 | param( 10 | [Parameter(ValueFromRemainingArguments=$true)] $params 11 | ) 12 | $ErrorActionPreference = "Continue" 13 | $allOutput = & git.exe $params 2>&1 14 | 15 | $allOutput | ForEach-Object { 16 | if ($_ -is [System.Management.Automation.ErrorRecord]) 17 | { 18 | $message = $_.Exception.Message 19 | if ($message -match '^warning: ') 20 | { 21 | Write-Warning $message 22 | } 23 | else 24 | { 25 | Write-Error $message 26 | } 27 | } 28 | else 29 | { 30 | Write-Output $_ 31 | } 32 | } 33 | } 34 | 35 | Export-ModuleMember -Function @( 36 | 'git' 37 | ) 38 | -------------------------------------------------------------------------------- /eng/test.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | 3 | - task: DotNetCoreCLI@2 4 | displayName: Test C# (dotnet test) 5 | inputs: 6 | command: custom 7 | projects: | 8 | $(Build.SourcesDirectory)\dnceng-shared.sln 9 | custom: test 10 | arguments: > 11 | --configuration $(_BuildConfig) 12 | --filter "TestCategory!=PostDeployment&TestCategory!=Nightly&TestCategory!=PreDeployment" 13 | --no-build 14 | --logger "trx;LogFilePrefix=TestResults-" 15 | -v normal 16 | -- 17 | "RunConfiguration.ResultsDirectory=$(Build.ArtifactStagingDirectory)\TestResults" 18 | RunConfiguration.MapCpuCount=4 19 | env: 20 | NUGET_PACKAGES: $(Build.SourcesDirectory)/.packages 21 | condition: succeededOrFailed() 22 | 23 | - task: PublishTestResults@2 24 | displayName: Publish Core Test Results 25 | condition: succeededOrFailed() 26 | inputs: 27 | testRunner: VSTest 28 | testResultsFiles: '**/TestResults-*' 29 | searchFolder: $(Build.ArtifactStagingDirectory)\TestResults 30 | testRunTitle: Basic Tests 31 | mergeTestResults: true 32 | configuration: $(_BuildConfig) 33 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "8.0.115", 4 | "allowPrerelease": true, 5 | "rollForward": "minor" 6 | }, 7 | "tools": { 8 | "dotnet": "8.0.115", 9 | "runtimes": { 10 | "dotnet": [ 11 | "3.1.32", 12 | "6.0.14" 13 | ] 14 | } 15 | }, 16 | "msbuild-sdks": { 17 | "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.25230.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/CoreHealthMonitor/CoreHealthMonitor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | true 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/CoreHealthMonitor/DriveMonitorOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace CoreHealthMonitor; 5 | 6 | public class DriveMonitorOptions 7 | { 8 | public long MinimumFreeSpaceBytes { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/MIcrosoft.DotNet.Internal.Logging/FormattableStringFormatter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.Extensions.Logging; 6 | 7 | namespace Microsoft.DotNet.Internal.Logging; 8 | 9 | internal static class FormattableStringFormatter 10 | { 11 | private class FormattingLogger : ILogger, IDisposable 12 | { 13 | public string LastLog; 14 | 15 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) 16 | { 17 | LastLog = formatter(state, exception); 18 | } 19 | 20 | public bool IsEnabled(LogLevel logLevel) 21 | { 22 | return true; 23 | } 24 | 25 | public IDisposable BeginScope(TState state) 26 | { 27 | return this; 28 | } 29 | 30 | public void Dispose() 31 | { 32 | } 33 | } 34 | 35 | public static string Format(string logFormatString, object[] args) 36 | { 37 | var logger = new FormattingLogger(); 38 | logger.Log(LogLevel.Error, logFormatString, args); 39 | return logger.LastLog; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/MIcrosoft.DotNet.Internal.Logging/Microsoft.DotNet.Internal.Logging.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/MIcrosoft.DotNet.Internal.Logging/OperationManagerOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Logging; 5 | 6 | public class OperationManagerOptions 7 | { 8 | public bool ShouldStartActivity { get; set; } = true; 9 | public bool ShouldCreateLoggingScope { get; set; } = true; 10 | } 11 | -------------------------------------------------------------------------------- /src/MIcrosoft.DotNet.Internal.Logging/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Microsoft.DotNet.Internal.Logging; 8 | 9 | public static class ServiceCollectionExtensions 10 | { 11 | public static IServiceCollection AddOperationTracking( 12 | this IServiceCollection collection, 13 | Action configure) 14 | { 15 | collection.AddSingleton(); 16 | collection.AddOptions(); 17 | collection.Configure(configure); 18 | return collection; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiPagination/ApiPaginationApplicationModelConvention.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Reflection; 5 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 6 | 7 | namespace Microsoft.AspNetCore.ApiPagination; 8 | 9 | public class ApiPaginationApplicationModelConvention : IApplicationModelConvention 10 | { 11 | public void Apply(ApplicationModel application) 12 | { 13 | foreach (ControllerModel controller in application.Controllers) 14 | { 15 | foreach (ActionModel action in controller.Actions) 16 | { 17 | var paginatedAttribute = action.ActionMethod.GetCustomAttribute(); 18 | if (paginatedAttribute != null) 19 | { 20 | foreach (ParameterModel param in paginatedAttribute.CreateParameterModels()) 21 | { 22 | param.Action = action; 23 | action.Parameters.Add(param); 24 | } 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiPagination/ApiPaginationMvcBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.Extensions.DependencyInjection; 7 | 8 | namespace Microsoft.AspNetCore.ApiPagination; 9 | 10 | [PublicAPI] 11 | public static class ApiPaginationMvcBuilderExtensions 12 | { 13 | public static IMvcBuilder AddApiPagination(this IMvcBuilder builder) 14 | { 15 | return builder.AddMvcOptions(ConfigureMvcOptions); 16 | } 17 | 18 | private static void ConfigureMvcOptions(MvcOptions options) 19 | { 20 | options.Conventions.Add(new ApiPaginationApplicationModelConvention()); 21 | } 22 | 23 | public static IMvcCoreBuilder AddApiPagination(this IMvcCoreBuilder builder) 24 | { 25 | return builder.AddMvcOptions(ConfigureMvcOptions); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiPagination/Microsoft.AspNetCore.ApiPagination.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Analyzers/KnownTypes.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.CodeAnalysis; 5 | 6 | namespace Microsoft.AspNetCore.ApiVersioning.Analyzers; 7 | 8 | internal class KnownTypes 9 | { 10 | public KnownTypes(Compilation compilation) 11 | { 12 | Controller = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Mvc.Controller"); 13 | Type = compilation.GetTypeByMetadataName("System.Type"); 14 | ApiVersionAttribute = 15 | compilation.GetTypeByMetadataName("Microsoft.AspNetCore.ApiVersioning.ApiVersionAttribute"); 16 | ProducesResponseTypeAttribute = 17 | compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute"); 18 | } 19 | 20 | public ITypeSymbol Type { get; } 21 | public ITypeSymbol Controller { get; } 22 | public ITypeSymbol ApiVersionAttribute { get; } 23 | public ITypeSymbol ProducesResponseTypeAttribute { get; } 24 | 25 | public bool HaveRequired() 26 | { 27 | return Type != null && Controller != null && ApiVersionAttribute != null && 28 | ProducesResponseTypeAttribute != null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Analyzers/Microsoft.AspNetCore.ApiVersioning.Analyzers.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | false 6 | true 7 | 8 | true 9 | $(NoWarn);RS2008 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Swashbuckle/ISwaggerVersioningScheme.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.OpenApi.Models; 6 | using Swashbuckle.AspNetCore.SwaggerGen; 7 | 8 | namespace Microsoft.AspNetCore.ApiVersioning.Swashbuckle; 9 | 10 | [PublicAPI] 11 | public interface ISwaggerVersioningScheme 12 | { 13 | void Apply(OpenApiOperation operation, OperationFilterContext context, string version); 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Swashbuckle/Microsoft.AspNetCore.ApiVersioning.Swashbuckle.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Swashbuckle/SwaggerApiResponseAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Net; 6 | using Swashbuckle.AspNetCore.Annotations; 7 | 8 | namespace Microsoft.AspNetCore.ApiVersioning.Swashbuckle; 9 | 10 | /// 11 | /// Implementation of that is not inherited. 12 | /// 13 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = false)] 14 | public class SwaggerApiResponseAttribute : SwaggerResponseAttribute 15 | { 16 | public SwaggerApiResponseAttribute(int statusCode, string description = null, Type type = null) : base(statusCode, description, type) 17 | { 18 | } 19 | 20 | public SwaggerApiResponseAttribute(HttpStatusCode statusCode, string description = null, Type type = null) : 21 | this((int) statusCode, description, type) 22 | { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Swashbuckle/SwaggerModelBindingOperationFilter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Linq; 5 | using Microsoft.AspNetCore.Mvc.ApiExplorer; 6 | using Microsoft.OpenApi.Models; 7 | using Swashbuckle.AspNetCore.SwaggerGen; 8 | 9 | namespace Microsoft.AspNetCore.ApiVersioning.Swashbuckle; 10 | 11 | public class SwaggerModelBindingOperationFilter : IOperationFilter 12 | { 13 | public void Apply(OpenApiOperation operation, OperationFilterContext context) 14 | { 15 | foreach (OpenApiParameter parameter in operation.Parameters) 16 | { 17 | // For some reason Swashbuckle doesn't honor ModelMetadata.IsRequired for parameters 18 | ApiParameterDescription apiParamDesc = 19 | context.ApiDescription.ParameterDescriptions.FirstOrDefault(p => p.Name == parameter.Name); 20 | if (apiParamDesc != null && apiParamDesc.ModelMetadata.IsRequired) 21 | { 22 | parameter.Required = true; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning.Swashbuckle/VersioningOperationFilter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.OpenApi.Models; 6 | using Swashbuckle.AspNetCore.Swagger; 7 | using Swashbuckle.AspNetCore.SwaggerGen; 8 | 9 | namespace Microsoft.AspNetCore.ApiVersioning.Swashbuckle; 10 | 11 | [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)] 12 | internal class VersioningOperationFilter : IOperationFilter 13 | { 14 | private readonly ISwaggerVersioningScheme _scheme; 15 | 16 | public VersioningOperationFilter(ISwaggerVersioningScheme scheme) 17 | { 18 | _scheme = scheme; 19 | } 20 | 21 | public void Apply(OpenApiOperation operation, OperationFilterContext context) 22 | { 23 | string version = context.ApiDescription.ActionDescriptor.RouteValues["version"]; 24 | _scheme.Apply(operation, context, version); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/ApiRemovedAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.AspNetCore.ApiVersioning; 7 | 8 | [AttributeUsage(AttributeTargets.Method)] 9 | public class ApiRemovedAttribute : Attribute 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/ApiVersioningExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using JetBrains.Annotations; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.ApiExplorer; 8 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using Microsoft.Extensions.Options; 11 | 12 | namespace Microsoft.AspNetCore.ApiVersioning; 13 | 14 | public static class ApiVersioningExtensions 15 | { 16 | [PublicAPI] 17 | public static IServiceCollection AddApiVersioning( 18 | this IServiceCollection services, 19 | Action configureOptions) 20 | { 21 | return services.AddSingleton() 22 | .AddSingleton() 23 | .AddSingleton, ApiVersioningMvcOptionsSetup>() 24 | .AddTransient() 25 | .Configure(configureOptions); 26 | } 27 | } 28 | 29 | public class ApiVersioningMvcOptionsSetup : IConfigureOptions 30 | { 31 | private readonly VersionedApiConvention _apiConvention; 32 | 33 | public ApiVersioningMvcOptionsSetup(VersionedApiConvention apiConvention) 34 | { 35 | _apiConvention = apiConvention; 36 | } 37 | 38 | public void Configure(MvcOptions options) 39 | { 40 | options.Conventions.Add(_apiConvention); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/ApiVersioningOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Reflection; 6 | using JetBrains.Annotations; 7 | using Microsoft.AspNetCore.ApiVersioning.Schemes; 8 | 9 | namespace Microsoft.AspNetCore.ApiVersioning; 10 | 11 | [PublicAPI] 12 | public class ApiVersioningOptions 13 | { 14 | public Func GetVersion { get; set; } = DefaultGetVersion; 15 | public Func GetName { get; set; } = DefaultGetName; 16 | public IVersioningScheme VersioningScheme { get; set; } = new PathVersioningScheme(); 17 | 18 | [CanBeNull] 19 | public static string DefaultGetVersion(TypeInfo controllerType) 20 | { 21 | var attribute = controllerType.GetCustomAttribute(false); 22 | return attribute?.Version; 23 | } 24 | 25 | [NotNull] 26 | private static string DefaultGetName(TypeInfo controllerType) 27 | { 28 | return controllerType.Name.Substring(0, controllerType.Name.Length - 10); 29 | } 30 | } 31 | 32 | [PublicAPI] 33 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 34 | public class ApiVersionAttribute : Attribute 35 | { 36 | public ApiVersionAttribute(string version) 37 | { 38 | Version = version; 39 | } 40 | 41 | public string Version { get; } 42 | } 43 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/ApiVersioningOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using JetBrains.Annotations; 5 | using Microsoft.AspNetCore.ApiVersioning.Schemes; 6 | 7 | namespace Microsoft.AspNetCore.ApiVersioning; 8 | 9 | [PublicAPI] 10 | public static class ApiVersioningOptionsExtensions 11 | { 12 | public static ApiVersioningOptions VersionByHeader(this ApiVersioningOptions options) 13 | { 14 | return options.VersionByHeader("X-Api-Version"); 15 | } 16 | 17 | public static ApiVersioningOptions VersionByHeader(this ApiVersioningOptions options, string headerName) 18 | { 19 | options.VersioningScheme = new HeaderVersioningScheme(headerName); 20 | return options; 21 | } 22 | 23 | public static ApiVersioningOptions VersionByQuery(this ApiVersioningOptions options) 24 | { 25 | return options.VersionByQuery("api-version"); 26 | } 27 | 28 | public static ApiVersioningOptions VersionByQuery(this ApiVersioningOptions options, string parameterName) 29 | { 30 | options.VersioningScheme = new QueryVersioningScheme(parameterName); 31 | return options; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/IVersioningScheme.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 5 | 6 | namespace Microsoft.AspNetCore.ApiVersioning; 7 | 8 | public interface IVersioningScheme 9 | { 10 | void Apply(SelectorModel model, string version); 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/Microsoft.AspNetCore.ApiVersioning.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/Schemes/HeaderVersioningScheme.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Mvc.ActionConstraints; 5 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 6 | 7 | namespace Microsoft.AspNetCore.ApiVersioning.Schemes; 8 | 9 | public class HeaderVersioningScheme : IVersioningScheme 10 | { 11 | public HeaderVersioningScheme(string headerName) 12 | { 13 | HeaderName = headerName; 14 | } 15 | 16 | public string HeaderName { get; } 17 | 18 | public void Apply(SelectorModel model, string version) 19 | { 20 | AttributeRouteModel attributeRouteModel = model.AttributeRouteModel; 21 | attributeRouteModel.Template = "api/" + attributeRouteModel.Template; 22 | model.ActionConstraints.Add(new Constraint(HeaderName, version)); 23 | } 24 | 25 | private class Constraint : IActionConstraint 26 | { 27 | private readonly string _headerName; 28 | private readonly string _version; 29 | 30 | public Constraint(string headerName, string version) 31 | { 32 | _headerName = headerName; 33 | _version = version; 34 | } 35 | 36 | public bool Accept(ActionConstraintContext context) 37 | { 38 | return context.RouteContext.HttpContext.Request.Headers[_headerName] == _version; 39 | } 40 | 41 | public int Order { get; } = 100; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/Schemes/PathVersioningScheme.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 5 | 6 | namespace Microsoft.AspNetCore.ApiVersioning.Schemes; 7 | 8 | public class PathVersioningScheme : IVersioningScheme 9 | { 10 | public void Apply(SelectorModel model, string version) 11 | { 12 | AttributeRouteModel attributeRouteModel = model.AttributeRouteModel; 13 | attributeRouteModel.Template = $"api/{version}/{attributeRouteModel.Template}"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore.ApiVersioning/SuppressVersionErrorsAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.AspNetCore.ApiVersioning; 7 | 8 | /// 9 | /// This attribute marks the attributed type as "versioned" so the roslyn analyzer won't warn about it. 10 | /// This should only be used on types that never change and are shared by all api versions, like error models. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public class SuppressVersionErrorsAttribute : Attribute 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/Authentication/TokenCredentialProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | using Azure.Core; 7 | using Azure.Identity; 8 | using Microsoft.DncEng.Configuration.Extensions; 9 | 10 | namespace Microsoft.DncEng.CommandLineLib.Authentication; 11 | 12 | public class TokenCredentialProvider 13 | { 14 | private readonly IConsole _console; 15 | private readonly InteractiveTokenCredentialProvider _interactiveTokenCredentialProvider; 16 | 17 | public TokenCredentialProvider(IConsole console, InteractiveTokenCredentialProvider interactiveTokenCredentialProvider) 18 | { 19 | _console = console; 20 | _interactiveTokenCredentialProvider = interactiveTokenCredentialProvider; 21 | } 22 | 23 | public async Task GetCredentialAsync() 24 | { 25 | var creds = new List 26 | { 27 | new DefaultAzureCredential(new DefaultAzureCredentialOptions() 28 | { 29 | TenantId = ConfigurationConstants.MsftAdTenantId, 30 | }) 31 | }; 32 | 33 | if (_console.IsInteractive) 34 | { 35 | creds.Add(await _interactiveTokenCredentialProvider.GetCredentialAsync()); 36 | } 37 | 38 | return new ChainedTokenCredential(creds.ToArray()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/CommandOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.DncEng.CommandLineLib; 8 | 9 | public class CommandOptions : ICommandOptions 10 | { 11 | private readonly Dictionary _options = new Dictionary(); 12 | 13 | public T GetOptions() 14 | { 15 | return (T) _options[typeof(T)]; 16 | } 17 | 18 | public void RegisterOptions(Command options) 19 | { 20 | _options.Add(options.GetType(), options); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/DefaultConsoleBackend.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.IO; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.DncEng.CommandLineLib; 9 | 10 | public class DefaultConsoleBackend : IConsoleBackend 11 | { 12 | public TextWriter Out => Console.Out; 13 | public TextWriter Error => Console.Error; 14 | public TextReader In => Console.In; 15 | 16 | public void SetColor(ConsoleColor color) 17 | { 18 | Console.ForegroundColor = color; 19 | } 20 | 21 | public void ResetColor() 22 | { 23 | Console.ResetColor(); 24 | } 25 | 26 | public Task ReadLineAsync() 27 | { 28 | return Console.In.ReadLineAsync(); 29 | } 30 | 31 | public async Task PromptAsync(string message) 32 | { 33 | // Purge the input buffer so piped in or previously typed text doesn't count 34 | while (Console.KeyAvailable) 35 | { 36 | Console.ReadKey(true); 37 | } 38 | 39 | await Console.Out.WriteAsync(message); 40 | 41 | string line = await Console.In.ReadLineAsync(); 42 | return line; 43 | } 44 | 45 | public bool IsInteractive => !(Console.IsOutputRedirected || Console.IsInputRedirected || Console.IsErrorRedirected); 46 | } 47 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/ExitCodes.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DncEng.CommandLineLib; 5 | 6 | public class ExitCodes 7 | { 8 | public const int Success = 0; 9 | public const int UnknownArgument = 1; 10 | public const int MissingCommand = 2; 11 | public const int RequiredParameter = 3; 12 | public const int UnhandledException = 4; 13 | public const int Break = 5; 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/FailWithExitCodeException.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DncEng.CommandLineLib; 7 | 8 | public class FailWithExitCodeException : Exception 9 | { 10 | public int ExitCode { get; } 11 | public bool ShowMessage { get; } 12 | 13 | public FailWithExitCodeException(int exitCode, string message = null) : base(message) 14 | { 15 | ShowMessage = !string.IsNullOrEmpty(message); 16 | ExitCode = exitCode; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/GlobalCommand.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Mono.Options; 5 | 6 | namespace Microsoft.DncEng.CommandLineLib; 7 | 8 | public class GlobalCommand : Command 9 | { 10 | public override OptionSet GetOptions() 11 | { 12 | return new OptionSet 13 | { 14 | { 15 | "verbose|v", "Increase logging verbosity up to 2 (default 1)", 16 | v => Verbosity = BumpVerbosity(Verbosity) 17 | }, 18 | { 19 | "quiet|q", "Suppress most output (except critical failures or prompts)", 20 | q => Verbosity = VerbosityLevel.Quiet 21 | }, 22 | {"help|h|?", "Show help", h => Help = true}, 23 | }; 24 | } 25 | 26 | public bool Help { get; set; } 27 | public VerbosityLevel Verbosity { get; set; } = VerbosityLevel.Normal; 28 | 29 | private static VerbosityLevel BumpVerbosity(VerbosityLevel verbosity) 30 | { 31 | verbosity++; 32 | if (verbosity > VerbosityLevel.Verbose) 33 | { 34 | verbosity = VerbosityLevel.Verbose; 35 | } 36 | 37 | return verbosity; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/ICommandOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DncEng.CommandLineLib; 5 | 6 | /// 7 | /// Used to get the value of other command options, such as 8 | /// 9 | /// 10 | public interface ICommandOptions 11 | { 12 | /// 13 | /// Get the parsed options for the given command type. 14 | /// If this command was not part of the current execution, and Exception is thrown 15 | /// 16 | /// Type of command to fetch 17 | /// If the given option type has not been parsed 18 | /// The parsed command options 19 | T GetOptions(); 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/ICommandRegistry.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.DncEng.CommandLineLib; 8 | 9 | public interface ICommandRegistry 10 | { 11 | IReadOnlyDictionary GetValidCommandAtScope(Type scope = null); 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/IConsoleBackend.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.IO; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.DncEng.CommandLineLib; 9 | 10 | public interface IConsoleBackend 11 | { 12 | TextWriter Out { get; } 13 | TextWriter Error { get; } 14 | TextReader In { get; } 15 | void SetColor(ConsoleColor color); 16 | void ResetColor(); 17 | Task PromptAsync(string message); 18 | bool IsInteractive { get; } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/ISystemClock.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DncEng.CommandLineLib; 7 | 8 | public interface ISystemClock 9 | { 10 | DateTimeOffset UtcNow { get; } 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/Microsoft.DncEng.CommandLineLib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/SystemClock.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DncEng.CommandLineLib; 7 | 8 | public class SystemClock : ISystemClock 9 | { 10 | public DateTimeOffset UtcNow => DateTimeOffset.UtcNow; 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.CommandLineLib/VerbosityLevel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DncEng.CommandLineLib; 5 | 6 | public enum VerbosityLevel 7 | { 8 | Quiet = 0, 9 | Normal = 1, 10 | Verbose = 2, 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.Configuration.Extensions/ConfigurationConstants.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DncEng.Configuration.Extensions; 5 | 6 | public static class ConfigurationConstants 7 | { 8 | public static string KeyVaultUriConfigurationKey => "KeyVaultUri"; 9 | public static string AppConfigurationUriConfigurationKey => "AppConfigurationUri"; 10 | public static string ManagedIdentityIdConfigurationKey => "Secrets:ManagedIdentityId"; 11 | public static string ReloadTimeSecondsConfigurationKey => "Secrets:ReloadTimeSeconds"; 12 | 13 | public static string MsftAdTenantId => "72f988bf-86f1-41af-91ab-2d7cd011db47"; 14 | 15 | // This group name must be kept in sync with 2 other places 16 | // - The ApplicationManifest.xml for the MaestroApplication service fabric 17 | // - The bootstrap.ps1 script, where this group gets created 18 | public static string ConfigurationAccessGroupName = "DncEngConfigurationUsers"; 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.Configuration.Extensions/MappedJsonConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.Configuration.Json; 7 | 8 | namespace Microsoft.DncEng.Configuration.Extensions; 9 | 10 | public class MappedJsonConfigurationSource : JsonConfigurationSource 11 | { 12 | private readonly TimeSpan _reloadTime; 13 | private readonly Func _mapFunc; 14 | private readonly IServiceProvider _serviceProvider; 15 | 16 | public MappedJsonConfigurationSource( 17 | TimeSpan reloadTime, 18 | Func mapFunc, 19 | IServiceProvider serviceProvider) 20 | { 21 | _reloadTime = reloadTime; 22 | _mapFunc = mapFunc; 23 | _serviceProvider = serviceProvider; 24 | } 25 | 26 | public override IConfigurationProvider Build(IConfigurationBuilder builder) 27 | { 28 | EnsureDefaults(builder); 29 | return new MappedJsonConfigurationProvider(this, _reloadTime, _mapFunc, _serviceProvider); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.Configuration.Extensions/Microsoft.DncEng.Configuration.Extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0;net8.0 5 | 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Microsoft.DncEng.Configuration.Extensions/RegexConfigMapper.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace Microsoft.DncEng.Configuration.Extensions; 8 | 9 | public static class RegexConfigMapper 10 | { 11 | public static Func Create(Regex regex, Func keyMapper) 12 | { 13 | return value => 14 | { 15 | if (value == null) 16 | return null; 17 | 18 | return regex.Replace(value, match => 19 | { 20 | string key = match.Groups["key"].Value; 21 | return keyMapper(key); 22 | }); 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Authentication.Algorithms/Microsoft.DotNet.Authentication.Algorithms.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/GitHubApplicationClientFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | using Octokit; 6 | 7 | namespace Microsoft.DotNet.GitHub.Authentication; 8 | 9 | public class GitHubApplicationClientFactory : IGitHubApplicationClientFactory 10 | { 11 | private readonly IGitHubClientFactory _clientFactory; 12 | private readonly IGitHubTokenProvider _tokenProvider; 13 | 14 | public GitHubApplicationClientFactory(IGitHubClientFactory clientFactory, IGitHubTokenProvider tokenProvider) 15 | { 16 | _clientFactory = clientFactory; 17 | _tokenProvider = tokenProvider; 18 | } 19 | 20 | public async Task CreateGitHubClientAsync(string owner, string repo) 21 | { 22 | return _clientFactory.CreateGitHubClient(await _tokenProvider.GetTokenForRepository(owner, repo)); 23 | } 24 | 25 | public IGitHubClient CreateGitHubAppClient() 26 | { 27 | return _clientFactory.CreateGitHubClient(_tokenProvider.GetTokenForApp(), AuthenticationType.Bearer); 28 | } 29 | 30 | public IGitHubClient CreateGitHubAppClient(string name) 31 | { 32 | return _clientFactory.CreateGitHubClient(_tokenProvider.GetTokenForApp(name), AuthenticationType.Bearer); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/GitHubClientFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.Extensions.Options; 5 | using Octokit; 6 | using System; 7 | 8 | namespace Microsoft.DotNet.GitHub.Authentication; 9 | 10 | public class GitHubClientFactory : IGitHubClientFactory 11 | { 12 | private readonly IOptionsMonitor _githubClientOptions; 13 | 14 | public GitHubClientFactory(IOptionsMonitor githubClientOptions) 15 | { 16 | _githubClientOptions = githubClientOptions; 17 | } 18 | 19 | public GitHubClientOptions Options => _githubClientOptions.CurrentValue; 20 | 21 | public IGitHubClient CreateGitHubClient(string token) 22 | { 23 | return CreateGitHubClient(token, AuthenticationType.Oauth); 24 | } 25 | 26 | public IGitHubClient CreateGitHubClient(string token, AuthenticationType type) 27 | { 28 | if (Options?.ProductHeader == null) 29 | { 30 | throw new InvalidOperationException($"A {nameof(GitHubClientOptions.ProductHeader)} is required for a GitHub client, but the value in {nameof(GitHubClientOptions)} is null."); 31 | } 32 | 33 | var client = new GitHubClient(Options.ProductHeader); 34 | 35 | if (!string.IsNullOrEmpty(token)) 36 | { 37 | client.Credentials = new Credentials(token, type); 38 | } 39 | 40 | return client; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/GitHubClientOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Octokit; 5 | 6 | namespace Microsoft.DotNet.GitHub.Authentication; 7 | 8 | public class GitHubClientOptions 9 | { 10 | public ProductHeaderValue ProductHeader { get; set; } 11 | public string[] AllowOrgs { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/GitHubHelper.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.GitHub.Authentication; 5 | 6 | public static class GitHubHelper 7 | { 8 | public static string GetRepositoryUrl(string organization, string repository) => $"https://github.com/{organization}/{repository}"; 9 | } 10 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/GitHubTokenProviderOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.GitHub.Authentication; 5 | 6 | public class GitHubTokenProviderOptions 7 | { 8 | public string PrivateKey { get; set; } 9 | public int GitHubAppId { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/IGitHubAppTokenProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.GitHub.Authentication; 5 | 6 | public interface IGitHubAppTokenProvider 7 | { 8 | string GetAppToken(); 9 | 10 | /// 11 | /// Get an app token using the configuration that corresponds to the logical name specified by . 12 | /// 13 | string GetAppToken(string name); 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/IGitHubApplicationClientFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | using Octokit; 6 | 7 | namespace Microsoft.DotNet.GitHub.Authentication; 8 | 9 | public interface IGitHubApplicationClientFactory 10 | { 11 | Task CreateGitHubClientAsync(string owner, string repo); 12 | IGitHubClient CreateGitHubAppClient(); 13 | 14 | /// 15 | /// Creates a GitHub App client configured the configuration that corresponds to the logical name specified by . 16 | /// 17 | IGitHubClient CreateGitHubAppClient(string name); 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/IGitHubClientFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Net.Http; 5 | using Octokit; 6 | 7 | namespace Microsoft.DotNet.GitHub.Authentication; 8 | 9 | public interface IGitHubClientFactory 10 | { 11 | IGitHubClient CreateGitHubClient(string token); 12 | IGitHubClient CreateGitHubClient(string token, AuthenticationType type); 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/IGitHubTokenProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | 6 | namespace Microsoft.DotNet.GitHub.Authentication; 7 | 8 | public interface IGitHubTokenProvider 9 | { 10 | Task GetTokenForInstallationAsync(long installationId); 11 | Task GetTokenForRepository(string repositoryUrl); 12 | string GetTokenForApp(); 13 | string GetTokenForApp(string name); 14 | void InvalidateTokenCacheAsync(long installationId); 15 | } 16 | 17 | public static class GitHubTokenProviderExtensions 18 | { 19 | public static Task GetTokenForRepository(this IGitHubTokenProvider provider, string organization, string repository) 20 | { 21 | return provider.GetTokenForRepository(GitHubHelper.GetRepositoryUrl(organization, repository)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/InstallationLookup.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | 6 | namespace Microsoft.DotNet.GitHub.Authentication; 7 | 8 | public interface IInstallationLookup 9 | { 10 | Task GetInstallationId(string repositoryUrl); 11 | Task IsOrganizationSupported(string org); 12 | } 13 | 14 | public static class InstallationLookup 15 | { 16 | public static Task GetInstallationId(this IInstallationLookup lookup, string organization, string repository) 17 | { 18 | return lookup.GetInstallationId(GitHubHelper.GetRepositoryUrl(organization, repository)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/Microsoft.DotNet.GitHub.Authentication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.GitHub.Authentication/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.DotNet.GitHub.Authentication; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Microsoft.DotNet.GitHub.Authentication; 8 | 9 | public static class ServiceCollectionExtensions 10 | { 11 | public static IServiceCollection AddGitHubTokenProvider(this IServiceCollection services) 12 | { 13 | return services 14 | .AddSingleton() 15 | .AddSingleton(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.AkaMsLinks/Microsoft.DotNet.Internal.AkaMsLinks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | false 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.AkaMsLinks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("Microsoft.DotNet.Internal.AkaMsLinks.Tests")] 7 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.DependencyInjection.Testing/Microsoft.DotNet.Internal.DependencyInjection.Testing.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.DependencyInjection/IClientFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.DependencyInjection; 5 | 6 | public interface IClientFactory 7 | { 8 | Reference GetClient(string name); 9 | } 10 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.DependencyInjection/Microsoft.DotNet.Internal.DependencyInjection.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.DependencyInjection/RefCountedObject.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading; 6 | 7 | namespace Microsoft.DotNet.Internal.DependencyInjection; 8 | 9 | public sealed class RefCountedObject 10 | { 11 | private int _refCount; 12 | 13 | public RefCountedObject(T value) 14 | { 15 | _refCount = 0; 16 | Value = value; 17 | } 18 | 19 | public T Value { get; } 20 | 21 | public void AddRef() 22 | { 23 | Interlocked.Increment(ref _refCount); 24 | } 25 | 26 | public void Release() 27 | { 28 | var newRefCount = Interlocked.Decrement(ref _refCount); 29 | if (newRefCount == 0) 30 | { 31 | if (Value is IDisposable disposable) 32 | { 33 | disposable.Dispose(); 34 | } 35 | else if (Value is IAsyncDisposable asyncDisposable) 36 | { 37 | asyncDisposable.DisposeAsync().AsTask().GetAwaiter().GetResult(); 38 | } 39 | } 40 | } 41 | } 42 | 43 | public struct Reference : IDisposable 44 | { 45 | private readonly RefCountedObject _referencedObject; 46 | 47 | public Reference(RefCountedObject value) 48 | { 49 | value.AddRef(); 50 | _referencedObject = value; 51 | } 52 | 53 | public T Value => _referencedObject.Value; 54 | 55 | public void Dispose() 56 | { 57 | _referencedObject.Release(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.DependencyInjection/ResolvingLazy.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Microsoft.DotNet.Internal.DependencyInjection; 8 | 9 | internal class ResolvingLazy : Lazy 10 | { 11 | public ResolvingLazy(IServiceProvider services) : base(services.GetRequiredService) 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.DependencyInjection/SingleClientFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.DependencyInjection; 5 | 6 | public class SingleClientFactory : IClientFactory 7 | { 8 | private readonly RefCountedObject _client; 9 | 10 | public SingleClientFactory(T client) 11 | { 12 | _client = new RefCountedObject(client); 13 | } 14 | 15 | public Reference GetClient(string name) 16 | { 17 | return new Reference(_client); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/AzureTableHealthReportingOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Health; 5 | 6 | public class AzureTableHealthReportingOptions 7 | { 8 | public const string HealthReportSettingsSection = "HealthReportSettings"; 9 | 10 | public string StorageAccountTablesUri { get; set; } 11 | public string TableName { get; set; } 12 | public string ManagedIdentityClientId { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/HealthReport.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public class HealthReport 9 | { 10 | public HealthReport(string serviceName, string instance, string subStatusName, HealthStatus health, string message, DateTimeOffset asOf) 11 | { 12 | Service= serviceName; 13 | Instance = instance; 14 | SubStatus = subStatusName; 15 | Health = health; 16 | Message = message; 17 | AsOf = asOf; 18 | } 19 | 20 | public string Service { get; } 21 | public string Instance { get; } 22 | public string SubStatus{ get; } 23 | public HealthStatus Health { get; } 24 | public string Message { get; } 25 | public DateTimeOffset AsOf { get; } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/HealthReportTableEntity.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Azure; 6 | using Azure.Data.Tables; 7 | 8 | namespace Microsoft.DotNet.Internal.Health; 9 | internal class HealthReportTableEntity : ITableEntity 10 | { 11 | public string PartitionKey { get; set; } 12 | public string RowKey { get; set; } 13 | public DateTimeOffset? Timestamp { get; set; } 14 | public ETag ETag { get; set; } 15 | public HealthStatus Status { get; set; } 16 | public string Message { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/HealthStatus.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Health; 5 | 6 | public enum HealthStatus 7 | { 8 | Invalid = 0, 9 | Healthy, 10 | Warning, 11 | Error, 12 | 13 | Unknown, 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IExternalHealthReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.DotNet.Internal.Health; 8 | 9 | public interface IExternalHealthReporter : IHealthReporter 10 | { 11 | Task> GetServiceStatusAsync(); 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IHealthReportProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.DotNet.Internal.Health; 8 | 9 | public interface IHealthReportProvider 10 | { 11 | Task UpdateStatusAsync(string serviceName, string instance, string subStatusName, HealthStatus status, string message); 12 | Task> GetAllStatusAsync(string serviceName); 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IHealthReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public interface IHealthReporter 9 | { 10 | Task UpdateStatusAsync(string subStatus, HealthStatus status, string message); 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IHealthReporterFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Health; 5 | 6 | public interface IHealthReporterFactory 7 | { 8 | IServiceHealthReporter ForService(); 9 | IInstanceHealthReporter ForInstance(); 10 | IExternalHealthReporter ForExternal(string serviceName); 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IInstanceAccessor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Health; 5 | 6 | public interface IInstanceAccessor 7 | { 8 | string GetCurrentInstanceName(); 9 | } 10 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IInstanceHealthReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using JetBrains.Annotations; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public interface IInstanceHealthReporter<[UsedImplicitly] TService> : IHealthReporter 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/IServiceHealthReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using JetBrains.Annotations; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public interface IServiceHealthReporter<[UsedImplicitly] T> : IHealthReporter 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/InstanceAccessor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Fabric; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public class InstanceAccessor : IInstanceAccessor 9 | { 10 | private readonly IInstanceAccessor _impl; 11 | 12 | public InstanceAccessor(ServiceContext context) 13 | { 14 | _impl = new ServiceFabricInstanceAccessor(context); 15 | } 16 | 17 | public InstanceAccessor() 18 | { 19 | _impl = new MachineNameInstanceAccessor(); 20 | } 21 | 22 | public string GetCurrentInstanceName() 23 | { 24 | return _impl.GetCurrentInstanceName(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/MachineNameInstanceAccessor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public class MachineNameInstanceAccessor : IInstanceAccessor 9 | { 10 | public string GetCurrentInstanceName() 11 | { 12 | return Environment.MachineName; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/Microsoft.DotNet.Internal.Health.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | true 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Health/ServiceFabricInstanceAccessor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Fabric; 5 | 6 | namespace Microsoft.DotNet.Internal.Health; 7 | 8 | public class ServiceFabricInstanceAccessor : IInstanceAccessor 9 | { 10 | private readonly ServiceContext _context; 11 | 12 | public ServiceFabricInstanceAccessor(ServiceContext context) 13 | { 14 | _context = context; 15 | } 16 | 17 | public string GetCurrentInstanceName() 18 | { 19 | return _context.ReplicaOrInstanceId.ToString(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.SymbolHelper/Microsoft.DotNet.Internal.SymbolHelper.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | true 6 | true 7 | 8 | 9 | 10 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.SymbolHelper/SymbolRequestHelpers.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | #nullable enable 4 | 5 | using System; 6 | using Microsoft.SymbolStore; 7 | 8 | namespace Microsoft.DotNet.Internal.SymbolHelper; 9 | 10 | internal static class SymbolRequestHelpers 11 | { 12 | internal static void ValidateRequestName(string? name, ITracer logger) 13 | { 14 | if (name is null or "") 15 | { 16 | logger.Error("Can't create a request with an empty name."); 17 | throw new ArgumentException("Name must be specified", nameof(name)); 18 | } 19 | 20 | if (name.Contains('+')) 21 | { 22 | // This is a restriction of the symbol request pipeline and not of symbol.exe 23 | // we share this between upload and promotion to prevent downstream issues. 24 | logger.Error("Requests can't contain '+' in their name"); 25 | throw new ArgumentException("Request can't contain a '+'", nameof(name)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions/ConfigureAllParametersAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions; 7 | 8 | [AttributeUsage(AttributeTargets.Method)] 9 | public class ConfigureAllParametersAttribute : Attribute 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions/Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | false 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions/TestDependencyInjectionSetupAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using JetBrains.Annotations; 6 | 7 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions; 8 | 9 | [AttributeUsage(AttributeTargets.Class)] 10 | [MeansImplicitUse(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature, ImplicitUseTargetFlags.WithMembers)] 11 | public class TestDependencyInjectionSetupAttribute : Attribute 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen/ConfigParameters.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen; 5 | 6 | internal class ConfigParameters 7 | { 8 | public ConfigParameters(string name, string type, bool isNullable) 9 | { 10 | Name = name; 11 | Type = type; 12 | IsNullable = isNullable; 13 | } 14 | 15 | public string Name { get; } 16 | public string Type { get; } 17 | public bool IsNullable { get; } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | 5 | true 6 | false 7 | false 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen/TestConfigDeclaration.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | using Microsoft.CodeAnalysis; 6 | using Microsoft.CodeAnalysis.CSharp.Syntax; 7 | 8 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen; 9 | 10 | internal class TestConfigDeclaration 11 | { 12 | public TestConfigDeclaration( 13 | string namespaceName, 14 | string parentName, 15 | ISymbol declaringClassSymbol, 16 | ClassDeclarationSyntax classDeclarationSyntax) 17 | { 18 | NamespaceName = namespaceName; 19 | ParentName = parentName; 20 | DeclaringClassSymbol = declaringClassSymbol; 21 | ClassDeclarationSyntax = classDeclarationSyntax; 22 | ConfigClassName = declaringClassSymbol.Name; 23 | } 24 | 25 | public string NamespaceName { get; } 26 | public string ParentName { get; } 27 | public ISymbol DeclaringClassSymbol { get; } 28 | public ClassDeclarationSyntax ClassDeclarationSyntax { get; } 29 | public string ConfigClassName { get; } 30 | public List Methods { get; } = new List(); 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.Utility/Microsoft.DotNet.Internal.Testing.Utility.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.Utility/NUnitLogger.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.Extensions.Logging; 6 | using NUnit.Framework; 7 | 8 | namespace Microsoft.DotNet.Internal.Testing.Utility; 9 | 10 | public class NUnitLogger : ILogger, ILoggerProvider 11 | { 12 | public void Dispose() 13 | { 14 | } 15 | 16 | public ILogger CreateLogger(string categoryName) 17 | { 18 | return this; 19 | } 20 | 21 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) 22 | { 23 | TestContext.WriteLine($"{logLevel} : {eventId} : {formatter(state, exception)}"); 24 | } 25 | 26 | public bool IsEnabled(LogLevel logLevel) 27 | { 28 | return true; 29 | } 30 | 31 | public IDisposable BeginScope(TState state) 32 | { 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.Utility/StringRegexAssertionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Text.RegularExpressions; 5 | using AwesomeAssertions; 6 | using AwesomeAssertions.Primitives; 7 | 8 | namespace Microsoft.DotNet.Internal.Testing.Utility; 9 | 10 | public static class StringRegexAssertionExtensions{ 11 | public static AndConstraint MatchRegex( 12 | this StringAssertions stringAssertion, 13 | Regex regularExpression, 14 | string because = "", 15 | params object[] becauseArgs 16 | ) 17 | { 18 | stringAssertion.Subject.Should().NotBeNull( 19 | $"Expected string to match regex {regularExpression}{(because != string.Empty ? " because " + because : string.Empty)}, but it was ."); 20 | 21 | regularExpression.IsMatch(stringAssertion.Subject).Should().BeTrue( 22 | $"Expected string to match regex {regularExpression}{(because != string.Empty ? " because " + because : string.Empty)}, but {stringAssertion.Subject} does not match."); 23 | 24 | return new AndConstraint(stringAssertion); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Internal.Testing.Utility/TestClock.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DotNet.Internal.Testing.Utility; 7 | 8 | public class TestClock : TimeProvider, Extensions.Internal.ISystemClock 9 | { 10 | public static readonly DateTime BaseTime = DateTime.Parse("2001-02-03T16:05:06Z"); 11 | public DateTimeOffset UtcNow { get; set; } = BaseTime; 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/IKustoClientProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | using System.Data; 6 | using System.Collections.Generic; 7 | 8 | namespace Microsoft.DotNet.Kusto; 9 | 10 | public interface IKustoClientProvider 11 | { 12 | Task ExecuteKustoQueryAsync(KustoQuery query); 13 | 14 | IAsyncEnumerable ExecuteStreamableKustoQuery(KustoQuery query); 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/KustoDataType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Kusto; 5 | 6 | public class KustoDataType 7 | { 8 | private KustoDataType(string cslDataType) 9 | { 10 | CslDataType = cslDataType; 11 | } 12 | 13 | public string CslDataType { get; } 14 | 15 | public static readonly KustoDataType String = new KustoDataType("string"); 16 | public static readonly KustoDataType Long = new KustoDataType("long"); 17 | public static readonly KustoDataType Int = new KustoDataType("int"); 18 | public static readonly KustoDataType Boolean = new KustoDataType("bool"); 19 | public static readonly KustoDataType DateTime = new KustoDataType("datetime"); 20 | public static readonly KustoDataType Guid = new KustoDataType("guid"); 21 | public static readonly KustoDataType TimeSpan = new KustoDataType("timespan"); 22 | public static readonly KustoDataType Real = new KustoDataType("real"); 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/KustoOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Kusto; 5 | 6 | public class KustoOptions 7 | { 8 | public string KustoClusterUri { get; set; } 9 | public string KustoIngestionUri { get; set; } 10 | public string Database { get; set; } 11 | public string ManagedIdentityId { get; set; } 12 | // For local development, use the Azure CLI for authentication 13 | public bool UseAzCliAuthentication { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/KustoParameter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Kusto; 5 | 6 | public class KustoParameter 7 | { 8 | public KustoParameter(string name, object value, KustoDataType type) 9 | { 10 | Name = name; 11 | Type = type; 12 | Value = value; 13 | } 14 | 15 | public string Name { get; } 16 | public KustoDataType Type { get; } 17 | public object Value { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/KustoQuery.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace Microsoft.DotNet.Kusto; 8 | 9 | public class KustoQuery 10 | { 11 | public KustoQuery() 12 | { 13 | Parameters = new List(); 14 | } 15 | 16 | public KustoQuery(string text, IEnumerable parameters) 17 | { 18 | Text = text; 19 | Parameters = parameters.ToList(); 20 | } 21 | 22 | public KustoQuery(string text) : this(text, new List()) 23 | { 24 | } 25 | 26 | public KustoQuery(string text, params KustoParameter[] parameters) : this(text, (IEnumerable) parameters) 27 | { 28 | } 29 | 30 | public List Parameters { get; } 31 | public string Text { get; set; } 32 | 33 | public void AddParameter(string name, object value, KustoDataType type) 34 | { 35 | Parameters.Add(new KustoParameter(name, value, type)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/KustoServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.Extensions.DependencyInjection; 5 | using System; 6 | using Microsoft.Extensions.Configuration; 7 | 8 | namespace Microsoft.DotNet.Kusto; 9 | 10 | public static class KustoServiceCollectionExtensions 11 | { 12 | public static IServiceCollection AddKustoClientProvider(this IServiceCollection services, string sectionName) 13 | { 14 | services.AddSingleton(); 15 | services.Configure(sectionName, (o, s) => 16 | { 17 | s.Bind(o); 18 | }); 19 | return services; 20 | } 21 | 22 | public static IServiceCollection AddKustoClientProvider(this IServiceCollection services, Action configure) 23 | { 24 | services.AddSingleton(); 25 | services.Configure(configure); 26 | return services; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Kusto/Microsoft.DotNet.Kusto.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | PreserveNewest 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Metrics/IMetricTracker.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.DotNet.Metrics; 7 | 8 | /// 9 | /// Interface for reporting metrics to the shared arcade metrics store 10 | /// 11 | public interface IMetricTracker 12 | { 13 | /// 14 | /// Record a single data point for the named metric, with optional dimensions. Metric value 15 | /// may be pre-aggregated depending on implementation 16 | /// 17 | /// Name of the metric to report 18 | /// Value for this instance of the metric 19 | /// Optional dimensions. Aggregations will never happen 20 | /// for metrics with different values for dimensions. Should generally not vary with time/work. 21 | /// An example would be the static queue id that something is pulled from 22 | void TrackMetric(string name, double value, IDictionary dimensions = default); 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Metrics/Microsoft.DotNet.Metrics.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | latest 5 | true 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/Actors/IActorImplementation.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.ServiceFabric.Actors; 5 | using Microsoft.ServiceFabric.Actors.Runtime; 6 | 7 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost.Actors; 8 | 9 | public interface IActorImplementation 10 | { 11 | void Initialize(ActorId actorId, IActorStateManager stateManager, IReminderManager reminderManager); 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/AppInsightsFlushLifecycle.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.ApplicationInsights.Channel; 5 | 6 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 7 | 8 | public class AppInsightsFlushLifecycle : Lifecycle 9 | { 10 | private readonly ITelemetryChannel _channel; 11 | 12 | public AppInsightsFlushLifecycle(ITelemetryChannel channel) 13 | { 14 | _channel = channel; 15 | } 16 | 17 | public override void OnStopping() 18 | { 19 | _channel.Flush(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/Extensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Options; 10 | 11 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 12 | 13 | public static class Extensions 14 | { 15 | public static Task AsTask(this CancellationToken cancellationToken) 16 | { 17 | if (!cancellationToken.CanBeCanceled) 18 | { 19 | return Task.FromException( 20 | new ArgumentException("The passed in CancellationToken cannot be canceled", nameof(cancellationToken))); 21 | } 22 | 23 | if (cancellationToken.IsCancellationRequested) 24 | { 25 | return Task.CompletedTask; 26 | } 27 | 28 | var tcs = new TaskCompletionSource(); 29 | cancellationToken.Register(s => ((TaskCompletionSource) s!).TrySetCanceled(cancellationToken), tcs); 30 | return tcs.Task; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/IServiceImplementation.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 9 | 10 | public interface IServiceImplementation 11 | { 12 | Task RunAsync(CancellationToken cancellationToken); 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/LoadReporting/EmptyServiceLoadReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 5 | 6 | public class EmptyServiceLoadReporter : IServiceLoadReporter 7 | { 8 | public void ReportLoad(string name, int value) 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/LoadReporting/IServiceLoadReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 5 | 6 | /// 7 | /// This type enables reporting load metrics to service fabric 8 | /// 9 | public interface IServiceLoadReporter 10 | { 11 | /// 12 | /// Reports a service fabric load metric. 13 | /// 14 | /// The load metric name 15 | /// The load metric value 16 | void ReportLoad(string name, int value); 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/LoadReporting/StatefulServiceLoadReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Fabric; 5 | 6 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 7 | 8 | public class StatefulServiceLoadReporter : IServiceLoadReporter 9 | { 10 | private readonly IStatefulServicePartition _partition; 11 | 12 | public StatefulServiceLoadReporter(IStatefulServicePartition partition) 13 | { 14 | _partition = partition; 15 | } 16 | 17 | public void ReportLoad(string name, int value) 18 | { 19 | _partition.ReportLoad(new[] {new LoadMetric(name, value)}); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/LoadReporting/StatelessServiceLoadReporter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Fabric; 5 | 6 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 7 | 8 | public class StatelessServiceLoadReporter : IServiceLoadReporter 9 | { 10 | private readonly IStatelessServicePartition _partition; 11 | 12 | public StatelessServiceLoadReporter(IStatelessServicePartition partition) 13 | { 14 | _partition = partition; 15 | } 16 | 17 | public void ReportLoad(string name, int value) 18 | { 19 | _partition.ReportLoad(new[] {new LoadMetric(name, value)}); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/LoggedServiceRemoting/ServiceHostActorProxy.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Fabric; 6 | using Castle.DynamicProxy; 7 | using Microsoft.ApplicationInsights; 8 | using Microsoft.ServiceFabric.Actors; 9 | using Microsoft.ServiceFabric.Actors.Client; 10 | using Microsoft.ServiceFabric.Actors.Remoting.V2.FabricTransport.Client; 11 | 12 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 13 | 14 | public static class ServiceHostActorProxy 15 | { 16 | private static ProxyGenerator Generator { get; } = new ProxyGenerator(); 17 | 18 | private static ActorProxyFactory CreateFactory() 19 | { 20 | return new ActorProxyFactory( 21 | handler => new ActivityServiceRemotingClientFactory( 22 | new FabricTransportActorRemotingClientFactory(handler))); 23 | } 24 | 25 | public static T Create(ActorId actorId, TelemetryClient telemetryClient, ServiceContext context) 26 | where T : class, IActor 27 | { 28 | var actor = CreateFactory().CreateActorProxy(actorId); 29 | Uri serviceUri = actor.GetActorReference().ServiceUri; 30 | T proxy = Generator.CreateInterfaceProxyWithTargetInterface( 31 | actor, 32 | new LoggingServiceProxyInterceptor(telemetryClient, context, serviceUri.ToString())); 33 | return proxy; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/Microsoft.DotNet.ServiceFabric.ServiceHost.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True 5 | True -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/RichExceptionTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.ApplicationInsights.Channel; 6 | using Microsoft.ApplicationInsights.DataContracts; 7 | using Microsoft.ApplicationInsights.Extensibility; 8 | using Microsoft.Rest; 9 | 10 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 11 | 12 | internal class RichExceptionTelemetryInitializer : ITelemetryInitializer 13 | { 14 | public void Initialize(ITelemetry telemetry) 15 | { 16 | if (telemetry is ExceptionTelemetry exceptionTelemetry) 17 | { 18 | Exception ex = exceptionTelemetry.Exception; 19 | if (ex is HttpOperationException httpEx) 20 | { 21 | HttpResponseMessageWrapper res = httpEx.Response; 22 | exceptionTelemetry.Properties["statusCode"] = ((int) res.StatusCode).ToString(); 23 | string content = res.Content; 24 | if (content.Length > 512) 25 | { 26 | content = content.Substring(0, 512); 27 | } 28 | 29 | exceptionTelemetry.Properties["responseText"] = content; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/ScheduledService/CronScheduleAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using JetBrains.Annotations; 6 | 7 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 8 | 9 | [AttributeUsage(AttributeTargets.Method)] 10 | [MeansImplicitUse] 11 | public sealed class CronScheduleAttribute : Attribute 12 | { 13 | public CronScheduleAttribute(string schedule, string timezone) 14 | { 15 | Schedule = schedule; 16 | TimeZone = timezone; 17 | } 18 | 19 | public string Schedule { get; } 20 | public string TimeZone { get; } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/ScheduledService/FuncInvokingJob.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading.Tasks; 6 | using Quartz; 7 | 8 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 9 | 10 | [DisallowConcurrentExecution] 11 | internal sealed class FuncInvokingJob : IJob 12 | { 13 | public async Task Execute(IJobExecutionContext context) 14 | { 15 | var func = (Func) context.MergedJobDataMap["func"]; 16 | await func(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/ScheduledService/TimeZones.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 5 | 6 | public static class TimeZones 7 | { 8 | public const string UTC = "UTC"; 9 | public const string PST = "Pacific Standard Time"; 10 | } 11 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/ServiceFabricHelpers.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | 6 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 7 | 8 | public static class ServiceFabricHelpers 9 | { 10 | public static bool RunningInServiceFabric() 11 | { 12 | string fabricApplication = Environment.GetEnvironmentVariable("Fabric_ApplicationName"); 13 | return !string.IsNullOrEmpty(fabricApplication); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.ServiceFabric.ServiceHost/ServiceFabricLookup.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Fabric; 5 | using Microsoft.ApplicationInsights; 6 | using Microsoft.ServiceFabric.Actors; 7 | 8 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost; 9 | 10 | public interface IActorProxyFactory 11 | { 12 | TActor Lookup(ActorId id); 13 | } 14 | 15 | public class ActorProxyFactory : IActorProxyFactory where TActor : class, IActor 16 | { 17 | private readonly TelemetryClient _telemetryClient; 18 | private readonly ServiceContext _serviceContext; 19 | 20 | public ActorProxyFactory(TelemetryClient telemetryClient = null, ServiceContext serviceContext = null) 21 | { 22 | _telemetryClient = telemetryClient; 23 | _serviceContext = serviceContext; 24 | } 25 | 26 | public TActor Lookup(ActorId id) 27 | { 28 | return ServiceHostActorProxy.Create(id, _telemetryClient, _serviceContext); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/DefaultHttpHandlerConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Net.Http; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Http; 8 | 9 | namespace Microsoft.DotNet.Services.Utility; 10 | 11 | internal class DefaultHttpHandlerConfiguration : IHttpMessageHandlerBuilderFilter where T : DelegatingHandler 12 | { 13 | private readonly IServiceProvider _services; 14 | 15 | public DefaultHttpHandlerConfiguration(IServiceProvider services) 16 | { 17 | _services = services; 18 | } 19 | 20 | public Action Configure(Action next) 21 | { 22 | return builder => 23 | { 24 | builder.AdditionalHandlers.Add(ActivatorUtilities.CreateInstance(_services)); 25 | next(builder); 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/DefaultHttpHandlerConfigurationExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Net.Http; 5 | using Microsoft.DotNet.Services.Utility; 6 | using Microsoft.Extensions.Http; 7 | 8 | // ReSharper disable once CheckNamespace 9 | namespace Microsoft.Extensions.DependencyInjection; 10 | 11 | public static class DefaultHttpHandlerConfigurationExtensions 12 | { 13 | /// 14 | /// Add a handler that will be applied to all HttpClients returned from IHttpClientFactory 15 | /// 16 | public static IServiceCollection AddDefaultHttpHandler(this IServiceCollection services) where T : DelegatingHandler 17 | { 18 | services.AddSingleton>(); 19 | return services; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/GitHelpers.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Services.Utility; 5 | 6 | public static class GitHelpers 7 | { 8 | private const string RefsHeadsPrefix = "refs/heads/"; 9 | private const string SlashRefsHeadsPrefix = "/refs/heads/"; 10 | 11 | public static string NormalizeBranchName(string branch) 12 | { 13 | if (branch != null) 14 | { 15 | if (branch.StartsWith(RefsHeadsPrefix)) { 16 | return branch.Substring(RefsHeadsPrefix.Length); 17 | } 18 | else if (branch.StartsWith(SlashRefsHeadsPrefix)) 19 | { 20 | return branch.Substring(SlashRefsHeadsPrefix.Length); 21 | } 22 | } 23 | return branch; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/Microsoft.DotNet.Services.Utility.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/RetryAllHandler.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.Extensions.Logging; 5 | using System.Net.Http; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Microsoft.DotNet.Services.Utility; 11 | 12 | public class RetryAllHandler : DelegatingHandler 13 | { 14 | private readonly ILogger _logger; 15 | private readonly ExponentialRetry _retry; 16 | 17 | public RetryAllHandler(ILogger logger, ExponentialRetry retry) 18 | { 19 | _logger = logger; 20 | _retry = retry; 21 | } 22 | 23 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 24 | { 25 | return await _retry.RetryAsync(async cancellationToken => 26 | { 27 | var response = await base.SendAsync(request, cancellationToken); 28 | 29 | response.EnsureSuccessStatusCode(); 30 | 31 | return response; 32 | }, 33 | ex => _logger.LogWarning("Exception thrown during getting the log `{exception}`, retrying", ex), 34 | _ => true, 35 | cancellationToken); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/obj/Microsoft.DotNet.Services.Utility.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj": {} 5 | }, 6 | "projects": { 7 | "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj": { 8 | "restore": { 9 | "projectUniqueName": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj", 10 | "projectPath": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj", 11 | "packagesPath": "C:\\Users\\dkurepa\\.nuget\\packages\\", 12 | "outputPath": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\obj\\", 13 | "projectStyle": "PackageReference", 14 | "configFilePaths": [ 15 | "C:\\Users\\dkurepa\\AppData\\Roaming\\NuGet\\NuGet.Config", 16 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" 17 | ], 18 | "sources": { 19 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 20 | "https://nuget.org/api/v2/": {}, 21 | "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json": {} 22 | } 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/obj/Microsoft.DotNet.Services.Utility.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/obj/Microsoft.DotNet.Services.Utility.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/obj/project.assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "targets": {}, 4 | "libraries": {}, 5 | "projectFileDependencyGroups": {}, 6 | "packageFolders": { 7 | "C:\\Users\\dkurepa\\.nuget\\packages\\": {} 8 | }, 9 | "project": { 10 | "restore": { 11 | "projectUniqueName": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj", 12 | "projectPath": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj", 13 | "packagesPath": "C:\\Users\\dkurepa\\.nuget\\packages\\", 14 | "outputPath": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\obj\\", 15 | "projectStyle": "PackageReference", 16 | "configFilePaths": [ 17 | "C:\\Users\\dkurepa\\AppData\\Roaming\\NuGet\\NuGet.Config", 18 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" 19 | ], 20 | "sources": { 21 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 22 | "https://nuget.org/api/v2/": {}, 23 | "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json": {} 24 | } 25 | } 26 | }, 27 | "logs": [ 28 | { 29 | "code": "NU1105", 30 | "level": "Error", 31 | "message": "Unable to read project information for 'Microsoft.DotNet.Services.Utility': Invalid framework identifier ''." 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Services.Utility/obj/project.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "dgSpecHash": "h+Ujl5HD9hj2ubLtYy3/pTk7Z5uPLUGLVyVnC5KjyND1NVAzekjppE6MUK2wV7Bw/E+KAR3Ikh5ghp6gnVnhxw==", 4 | "success": false, 5 | "projectFilePath": "C:\\Users\\dkurepa\\source\\repos\\dotnet-dnceng-shared\\src\\Microsoft.DotNet.Services.Utility\\Microsoft.DotNet.Services.Utility.csproj", 6 | "expectedPackageFiles": [], 7 | "logs": [ 8 | { 9 | "code": "NU1105", 10 | "level": "Error", 11 | "message": "Unable to read project information for 'Microsoft.DotNet.Services.Utility': Invalid framework identifier ''." 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/AccessToken/GetTokenHashContext.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace Microsoft.DotNet.Web.Authentication.AccessToken; 7 | 8 | public class GetTokenHashContext 9 | { 10 | public GetTokenHashContext(HttpContext httpContext, int tokenId) 11 | { 12 | HttpContext = httpContext; 13 | TokenId = tokenId; 14 | Succeeded = false; 15 | } 16 | 17 | public HttpContext HttpContext { get; } 18 | public int TokenId { get; } 19 | 20 | public string Hash { get; private set; } 21 | public TUser User { get; private set; } 22 | public bool Succeeded { get; private set; } 23 | 24 | public void Success(string hash, TUser user) 25 | { 26 | Hash = hash; 27 | User = user; 28 | Succeeded = true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/AccessToken/PersonalAccessTokenAuthenticationOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Authentication; 5 | 6 | namespace Microsoft.DotNet.Web.Authentication.AccessToken; 7 | 8 | public class PersonalAccessTokenAuthenticationOptions : AuthenticationSchemeOptions 9 | { 10 | public const int DefaultPasswordSize = 16; 11 | 12 | public new PersonalAccessTokenEvents Events 13 | { 14 | get => (PersonalAccessTokenEvents) base.Events; 15 | set => base.Events = value; 16 | } 17 | 18 | public int PasswordSize { get; set; } = DefaultPasswordSize; 19 | 20 | public string TokenName { get; set; } = "Bearer"; 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/AccessToken/PersonalAccessTokenDefaults.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Web.Authentication.AccessToken; 5 | 6 | public static class PersonalAccessTokenDefaults 7 | { 8 | public static string AuthenticationScheme { get; } = "PersonalAccessToken"; 9 | } 10 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/AccessToken/PersonalAccessTokenEvents.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Http; 7 | 8 | namespace Microsoft.DotNet.Web.Authentication.AccessToken; 9 | 10 | public class PersonalAccessTokenEvents 11 | { 12 | public Func, Task> OnSetTokenHash { get; set; } = context => 13 | throw new NotImplementedException("An implementation of SetTokenHash must be provided."); 14 | 15 | public Func, Task> OnGetTokenHash { get; set; } = context => 16 | throw new NotImplementedException("An implementation of GetTokenHash must be provided."); 17 | 18 | public Func GetTokenFromRequest { get; set; } = req => null; 19 | 20 | public Func, Task> OnValidatePrincipal { get; set; } = 21 | context => Task.CompletedTask; 22 | 23 | public virtual Task SetTokenHash(SetTokenHashContext context) 24 | { 25 | return OnSetTokenHash(context); 26 | } 27 | 28 | public virtual Task GetTokenHash(GetTokenHashContext context) 29 | { 30 | return OnGetTokenHash(context); 31 | } 32 | 33 | public virtual Task ValidatePrincipal(PersonalAccessTokenValidatePrincipalContext context) 34 | { 35 | return OnValidatePrincipal(context); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/AccessToken/SetTokenHashContext.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace Microsoft.DotNet.Web.Authentication.AccessToken; 7 | 8 | public class SetTokenHashContext 9 | { 10 | public SetTokenHashContext(HttpContext httpContext, TUser user, string name, string hash) 11 | { 12 | HttpContext = httpContext; 13 | User = user; 14 | Name = name; 15 | Hash = hash; 16 | } 17 | 18 | public HttpContext HttpContext { get; } 19 | 20 | public TUser User { get; } 21 | public string Name { get; } 22 | public string Hash { get; } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/DefaultAuthorizeActionModelConvention.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 8 | using Microsoft.AspNetCore.Mvc.Authorization; 9 | using Microsoft.AspNetCore.Mvc.Filters; 10 | 11 | namespace Microsoft.DotNet.Web.Authentication; 12 | 13 | public class DefaultAuthorizeActionModelConvention : IActionModelConvention 14 | { 15 | public DefaultAuthorizeActionModelConvention(string policyName) 16 | { 17 | Filter = new AuthorizeFilter(policyName); 18 | } 19 | 20 | public AuthorizeFilter Filter { get; } 21 | 22 | public void Apply(ActionModel action) 23 | { 24 | // ASP.NET 3.1 broke IAllowAnonymousFilter, just find the attribute ourselves 25 | // Otherwise it takes like 500 lines of code 26 | if (action.ActionMethod?.GetCustomAttributes(true).Any(a => a is IAllowAnonymous || a is IAuthorizeData) ?? false) 27 | { 28 | return; 29 | } 30 | 31 | IEnumerable attributes = action.Controller.Attributes.Concat(action.Attributes); 32 | if (attributes.Any(a => a is IAllowAnonymous || a is IAuthorizeData)) 33 | { 34 | return; 35 | } 36 | 37 | action.Filters.Add(Filter); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/GitHub/GitHubAuthenticationOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Authentication.OAuth; 5 | 6 | namespace Microsoft.DotNet.Web.Authentication.GitHub; 7 | 8 | public class GitHubAuthenticationOptions : OAuthOptions 9 | { 10 | public GitHubAuthenticationOptions() 11 | { 12 | AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; 13 | TokenEndpoint = "https://github.com/login/oauth/access_token"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.DotNet.Web.Authentication/Microsoft.DotNet.Web.Authentication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ServiceFabricMocks/MockTransaction.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading.Tasks; 6 | using Microsoft.ServiceFabric.Data; 7 | 8 | namespace ServiceFabricMocks; 9 | 10 | public class MockTransaction : ITransaction 11 | { 12 | public Task CommitAsync() 13 | { 14 | return Task.FromResult(true); 15 | } 16 | 17 | public void Abort() 18 | { 19 | } 20 | 21 | public long TransactionId => 0L; 22 | 23 | public long CommitSequenceNumber => throw new NotImplementedException(); 24 | 25 | public void Dispose() 26 | { 27 | } 28 | 29 | public Task GetVisibilitySequenceNumberAsync() 30 | { 31 | return Task.FromResult(0L); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/ServiceFabricMocks/ServiceFabricMocks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/CoreHealthMonitor.Tests/CoreHealthMonitor.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/CoreHealthMonitor.Tests/DependencyRegistrationTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using AwesomeAssertions; 6 | using Microsoft.DotNet.Internal.DependencyInjection.Testing; 7 | using Microsoft.DotNet.ServiceFabric.ServiceHost; 8 | using NUnit.Framework; 9 | 10 | namespace CoreHealthMonitor.Tests; 11 | 12 | [TestFixture] 13 | public class DependencyRegistrationTests 14 | { 15 | [Test] 16 | public void AreDependenciesRegistered() 17 | { 18 | DependencyInjectionValidation.IsDependencyResolutionCoherent( 19 | s => 20 | { 21 | Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "XUNIT"); 22 | ServiceHost.ConfigureDefaultServices(s); 23 | CoreHealthMonitorService.Configure(s); 24 | }, 25 | out string message, 26 | additionalScopedTypes: new[] {typeof(CoreHealthMonitorService)} 27 | ) 28 | .Should() 29 | .BeTrue(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Authentication.Algorithms.Tests/Microsoft.DotNet.Authentication.Algorithms.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.GitHub.Authentication.Tests/Microsoft.DotNet.GitHub.Authentication.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.AkaMsLinks.Test/Microsoft.DotNet.Internal.AkaMsLinks.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | false 9 | false 10 | true 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.DependencyInjection.Testing.Tests/Microsoft.DotNet.Internal.DependencyInjection.Testing.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | false 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.DependencyInjection.Tests/Microsoft.DotNet.Internal.DependencyInjection.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | false 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Health.Tests/Microsoft.DotNet.Internal.Health.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | false 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Health.Tests/MockHandler.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Net.Http; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Microsoft.DotNet.Internal.Health.Tests; 10 | 11 | public class MockHandler : HttpMessageHandler, IHttpClientFactory, IHttpMessageHandlerFactory 12 | { 13 | private readonly Func> _callback; 14 | 15 | public MockHandler(Func> callback) 16 | { 17 | _callback = callback; 18 | } 19 | 20 | protected override Task SendAsync( 21 | HttpRequestMessage request, 22 | CancellationToken cancellationToken) 23 | { 24 | return _callback(request); 25 | } 26 | 27 | public HttpClient CreateClient(string name) 28 | { 29 | return new HttpClient(CreateHandler(name)); // lgtm [cs/httpclient-checkcertrevlist-disabled] Used only for unit testing 30 | } 31 | 32 | public HttpMessageHandler CreateHandler(string name) 33 | { 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/ArrayTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using AwesomeAssertions; 6 | using Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using NUnit.Framework; 9 | 10 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests; 11 | 12 | public partial class ArrayTests 13 | { 14 | [TestDependencyInjectionSetup] 15 | public static class TestDataConfiguration 16 | { 17 | public static Func Values( 18 | IServiceCollection collection, 19 | string[] values) 20 | { 21 | return _ => values; 22 | } 23 | } 24 | 25 | [Test] 26 | public void Defaults() 27 | { 28 | using TestData testData = TestData.Default.Build(); 29 | testData.Values.Should().BeNull(); 30 | } 31 | 32 | [Test] 33 | public void WithValue() 34 | { 35 | using TestData testData = TestData 36 | .Default 37 | .WithValues(new[] { "pizza", "banana" }) 38 | .Build(); 39 | testData.Values.Should().NotBeNull() 40 | .And.BeEquivalentTo("pizza", "banana"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/Injectable.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests; 8 | 9 | public class Injectable : IDisposable, IAsyncDisposable 10 | { 11 | public Injectable(string value) 12 | { 13 | Value = value; 14 | } 15 | 16 | public string Value { get; } 17 | 18 | public bool IsSyncDisposeCalled { get; private set; } 19 | public bool IsAsyncDisposeCalled { get; private set; } 20 | 21 | public void Dispose() 22 | { 23 | IsSyncDisposeCalled = true; 24 | } 25 | 26 | public ValueTask DisposeAsync() 27 | { 28 | IsAsyncDisposeCalled = true; 29 | return default; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | false 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/NoConfigTest.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System.Threading.Tasks; 5 | using Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using NUnit.Framework; 8 | 9 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests; 10 | 11 | public partial class NoConfigTest 12 | { 13 | [TestDependencyInjectionSetup] 14 | public static class TestDataConfiguration 15 | { 16 | public static void Empty(IServiceCollection collection) 17 | { 18 | } 19 | } 20 | 21 | [Test] 22 | public void ValidateSync() 23 | { 24 | using TestData testData = TestData.Default.Build(); 25 | } 26 | 27 | [Test] 28 | public async Task ValidateAsyncBuild() 29 | { 30 | using TestData testData = await TestData.Default.BuildAsync(); 31 | } 32 | 33 | [Test] 34 | public async Task ValidateAsyncDispose() 35 | { 36 | await using TestData testData = TestData.Default.Build(); 37 | } 38 | 39 | [Test] 40 | public async Task ValidateAsyncAll() 41 | { 42 | await using TestData testData = await TestData.Default.BuildAsync(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/NoParameterValueTest.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using AwesomeAssertions; 6 | using Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using NUnit.Framework; 9 | 10 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests; 11 | 12 | public partial class NoParameterValueTest 13 | { 14 | private const string TestValue = "TEST-NoParameterValueTest"; 15 | 16 | [TestDependencyInjectionSetup] 17 | private static class TestDataConfig 18 | { 19 | public static Func Injectable(IServiceCollection collection) 20 | { 21 | collection.AddSingleton(s => new Injectable(TestValue)); 22 | return s => s.GetRequiredService(); 23 | } 24 | } 25 | 26 | [Test] 27 | public void Validate() 28 | { 29 | using TestData testData = TestData.Default.Build(); 30 | testData.Injectable.Value.Should().Be(TestValue); 31 | } 32 | } 33 | 34 | //public partial class NoParameterValueTest 35 | //{ 36 | // [TestDependencyInjectionSetup] 37 | // private static class TestDataConfig 38 | // { 39 | // } 40 | //} 41 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/Ref.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests; 5 | 6 | public class Ref 7 | { 8 | public T Value { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests/WithParameterValueTest.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using AwesomeAssertions; 6 | using Microsoft.DotNet.Internal.Testing.DependencyInjection.Abstractions; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using NUnit.Framework; 9 | 10 | namespace Microsoft.DotNet.Internal.Testing.DependencyInjectionCodeGen.Tests; 11 | 12 | public partial class WithParameterValueTest 13 | { 14 | [TestDependencyInjectionSetup] 15 | private static class TestDataConfig 16 | { 17 | public static Func Injectable(IServiceCollection collection, string value) 18 | { 19 | collection.AddSingleton(s => new Injectable(value)); 20 | return s => s.GetRequiredService(); 21 | } 22 | } 23 | 24 | [Test] 25 | public void ValidateDefault() 26 | { 27 | using TestData testData = TestData.Default.Build(); 28 | testData.Injectable.Value.Should().BeNull(); 29 | } 30 | 31 | [Test] 32 | public void ValidateValue() 33 | { 34 | const string testValue = "TEST-WithParameterValueTest"; 35 | using TestData testData = TestData.Default.WithValue(testValue).Build(); 36 | testData.Injectable.Value.Should().Be(testValue); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Kusto.Tests/Microsoft.DotNet.Kusto.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | win-x64 4 | 5 | false 6 | false 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Kusto.Tests/MockOptionMonitor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using Microsoft.Extensions.Options; 6 | using Moq; 7 | 8 | namespace Microsoft.DotNet.Kusto.Tests; 9 | 10 | public static class MockOptionMonitor 11 | { 12 | public static MockOptionMonitor Create(TOptions opts) where TOptions : class, new() => new MockOptionMonitor(opts); 13 | } 14 | 15 | public class MockOptionMonitor : IOptionsMonitor, IOptionsSnapshot, IOptions 16 | where TOptions : class, new() 17 | { 18 | public MockOptionMonitor(TOptions value) 19 | { 20 | Value = value; 21 | } 22 | 23 | TOptions IOptionsMonitor.Get(string name) => Value; 24 | 25 | public IDisposable OnChange(Action listener) 26 | { 27 | return Mock.Of(); 28 | } 29 | 30 | public TOptions CurrentValue => Value; 31 | public TOptions Value { get; } 32 | TOptions IOptionsSnapshot.Get(string name) => Value; 33 | } 34 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.ServiceFabric.ServiceHost.Tests/ExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using AwesomeAssertions; 8 | using NUnit.Framework; 9 | 10 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost.Tests; 11 | 12 | [TestFixture] 13 | public class ExtensionsTests 14 | { 15 | [Test] 16 | public async Task NonCancelableThrows() 17 | { 18 | await (((Func)(() => CancellationToken.None.AsTask()))).Should().ThrowExactlyAsync(); 19 | } 20 | 21 | [Test] 22 | public void PostCancellationChangesStateCompleted() 23 | { 24 | var source = new CancellationTokenSource(); 25 | Task task = source.Token.AsTask(); 26 | task.IsCompleted.Should().BeFalse(); 27 | source.Cancel(); 28 | task.IsCompleted.Should().BeTrue(); 29 | } 30 | 31 | [Test] 32 | public void PreCancelledReturnsCompleted() 33 | { 34 | var source = new CancellationTokenSource(); 35 | source.Cancel(); 36 | Task task = source.Token.AsTask(); 37 | task.IsCompleted.Should().BeTrue(); 38 | } 39 | 40 | [Test] 41 | public void WithoutCancellingNotComplete() 42 | { 43 | var source = new CancellationTokenSource(); 44 | Task task = source.Token.AsTask(); 45 | task.IsCompleted.Should().BeFalse(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.ServiceFabric.ServiceHost.Tests/FakeChannel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using Microsoft.ApplicationInsights.Channel; 7 | using Microsoft.ApplicationInsights.DataContracts; 8 | 9 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost.Tests; 10 | 11 | public class FakeChannel : ITelemetryChannel 12 | { 13 | public void Dispose() 14 | { 15 | } 16 | 17 | public void Send(ITelemetry item) 18 | { 19 | Telemetry.Add(item); 20 | } 21 | 22 | public void Flush() 23 | { 24 | } 25 | 26 | public bool? DeveloperMode { get; set; } 27 | public string EndpointAddress { get; set; } 28 | 29 | public List Telemetry { get; } = new List(); 30 | } 31 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.ServiceFabric.ServiceHost.Tests/IFakeService.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.ServiceFabric.ServiceHost.Tests; 5 | 6 | public interface IFakeService 7 | { 8 | string TestServiceMethod(); 9 | } 10 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.ServiceFabric.ServiceHost.Tests/Microsoft.DotNet.ServiceFabric.ServiceHost.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | win-x64 4 | 5 | false 6 | false 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/Controllers/AnonymousAttributeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Microsoft.DotNet.Web.Authentication.Tests.Controllers; 8 | 9 | [Route("test-auth/anonymous")] 10 | public class AnonymousAttributeController : ControllerBase 11 | { 12 | [AllowAnonymous] 13 | [Route("no")] 14 | public IActionResult NoAttribute() 15 | { 16 | return Ok("Anonymous:No:Value"); 17 | } 18 | 19 | [AllowAnonymous] 20 | [Route("anonymous")] 21 | public IActionResult AnonymousAttribute() 22 | { 23 | return Ok("Anonymous:Anonymous:Value"); 24 | } 25 | 26 | [Authorize, AllowAnonymous] 27 | [Route("any")] 28 | public IActionResult Any() 29 | { 30 | return Ok("Anonymous:Any:Value"); 31 | } 32 | 33 | [Authorize(Roles = "ActionRole"), AllowAnonymous] 34 | [Route("role")] 35 | public IActionResult RoleAttribute() 36 | { 37 | return Ok("Anonymous:Role:Value"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/Controllers/AnyAttributeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Microsoft.DotNet.Web.Authentication.Tests; 8 | 9 | [Route("test-auth/any")] 10 | [Authorize] 11 | public class AnyAttributeController : ControllerBase 12 | { 13 | [Route("no")] 14 | public IActionResult NoAttribute() 15 | { 16 | return Ok("Any:No:Value"); 17 | } 18 | 19 | [AllowAnonymous] 20 | [Route("anonymous")] 21 | public IActionResult AnonymousAttribute() 22 | { 23 | return Ok("Any:Anonymous:Value"); 24 | } 25 | 26 | [Authorize] 27 | [Route("any")] 28 | [HttpGet] 29 | public IActionResult Any() 30 | { 31 | return Ok("Any:Any:Value"); 32 | } 33 | 34 | [Authorize(Roles = "ActionRole")] 35 | [Route("role")] 36 | public IActionResult RoleAttribute() 37 | { 38 | return Ok("Any:Role:Value"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/Controllers/NoAttributeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Microsoft.DotNet.Web.Authentication.Tests.Controllers; 8 | 9 | [Route("test-auth/no")] 10 | public class NoAttributeController : ControllerBase 11 | { 12 | [Route("no")] 13 | public IActionResult NoAttribute() 14 | { 15 | return Ok("No:No:Value"); 16 | } 17 | 18 | [AllowAnonymous] 19 | [Route("anonymous")] 20 | public IActionResult AnonymousAttribute() 21 | { 22 | return Ok("No:Anonymous:Value"); 23 | } 24 | 25 | [Authorize] 26 | [Route("any")] 27 | public IActionResult Any() 28 | { 29 | return Ok("No:Any:Value"); 30 | } 31 | 32 | [Authorize(Roles = "ActionRole")] 33 | [Route("role")] 34 | public IActionResult RoleAttribute() 35 | { 36 | return Ok("No:Role:Value"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/Controllers/RoleAttributeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Microsoft.DotNet.Web.Authentication.Tests.Controllers; 8 | 9 | [Route("test-auth/role")] 10 | [Authorize(Roles = "ControllerRole")] 11 | public class RoleAttributeController : ControllerBase 12 | { 13 | [Route("no")] 14 | public IActionResult NoAttribute() 15 | { 16 | return Ok("Role:No:Value"); 17 | } 18 | 19 | [AllowAnonymous] 20 | [Route("anonymous")] 21 | public IActionResult AnonymousAttribute() 22 | { 23 | return Ok("Role:Anonymous:Value"); 24 | } 25 | 26 | [Authorize] 27 | [Route("any")] 28 | public IActionResult Any() 29 | { 30 | return Ok("Role:Any:Value"); 31 | } 32 | 33 | [Authorize(Roles = "ActionRole")] 34 | [Route("role")] 35 | public IActionResult RoleAttribute() 36 | { 37 | return Ok("Role:Role:Value"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/DefaultHttpContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Http.Extensions; 6 | 7 | namespace Microsoft.DotNet.Web.Authentication.Tests; 8 | 9 | internal static class DefaultHttpContextExtensions 10 | { 11 | internal static void SetUrl(this HttpRequest req, string url) 12 | { 13 | UriHelper.FromAbsolute(url, 14 | out string scheme, 15 | out HostString host, 16 | out PathString path, 17 | out QueryString queryString, 18 | out _ 19 | ); 20 | req.Scheme = scheme; 21 | req.Host = host; 22 | req.Path = path; 23 | req.QueryString = queryString; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/EmptyTestStartup.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | namespace Microsoft.DotNet.Web.Authentication.Tests; 5 | 6 | public class EmptyTestStartup 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /test/Microsoft.DotNet.Web.Authentication.Tests/Microsoft.DotNet.Web.Authentication.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | false 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | --------------------------------------------------------------------------------