forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'runtime-consolidation' from Extensions into 'primitives…
…-total'
- Loading branch information
Showing
741 changed files
with
75,997 additions
and
0 deletions.
There are no files selected for viewing
433 changes: 433 additions & 0 deletions
433
src/libraries/Common/src/Extensions/ActivatorUtilities/ActivatorUtilities.cs
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...raries/Common/src/Extensions/ActivatorUtilities/ActivatorUtilitiesConstructorAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
#if ActivatorUtilities_In_DependencyInjection | ||
namespace Microsoft.Extensions.DependencyInjection | ||
#else | ||
namespace Microsoft.Extensions.Internal | ||
#endif | ||
{ | ||
/// <summary> | ||
/// Marks the constructor to be used when activating type using <see cref="ActivatorUtilities"/>. | ||
/// </summary> | ||
|
||
#if ActivatorUtilities_In_DependencyInjection | ||
public | ||
#else | ||
// Do not take a dependency on this class unless you are explicitly trying to avoid taking a | ||
// dependency on Microsoft.AspNetCore.DependencyInjection.Abstractions. | ||
internal | ||
#endif | ||
class ActivatorUtilitiesConstructorAttribute: Attribute | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../src/Extensions/ActivatorUtilities/Microsoft.Extensions.ActivatorUtilities.Sources.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project> | ||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | ||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> | ||
|
||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)..\ParameterDefaultValue\ParameterDefaultValue.cs"> | ||
<Pack>true</Pack> | ||
<PackagePath>$(ContentTargetFolders)\cs\netstandard1.0\</PackagePath> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<Target Name="Compile" /> | ||
<Target Name="CopyFilesToOutputDirectory" /> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
src/libraries/Common/src/Extensions/ActivatorUtilities/ObjectFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
#if ActivatorUtilities_In_DependencyInjection | ||
namespace Microsoft.Extensions.DependencyInjection | ||
#else | ||
namespace Microsoft.Extensions.Internal | ||
#endif | ||
{ | ||
|
||
/// <summary> | ||
/// The result of <see cref="ActivatorUtilities.CreateFactory(Type, Type[])"/>. | ||
/// </summary> | ||
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> to get service arguments from.</param> | ||
/// <param name="arguments">Additional constructor arguments.</param> | ||
/// <returns>The instantiated type.</returns> | ||
#if ActivatorUtilities_In_DependencyInjection | ||
public | ||
#else | ||
internal | ||
#endif | ||
delegate object ObjectFactory(IServiceProvider serviceProvider, object[] arguments); | ||
} |
74 changes: 74 additions & 0 deletions
74
src/libraries/Common/src/Extensions/BenchmarkRunner/AspNetCoreBenchmarkAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using BenchmarkDotNet.Configs; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)] | ||
internal class AspNetCoreBenchmarkAttribute : Attribute, IConfigSource | ||
{ | ||
public AspNetCoreBenchmarkAttribute() | ||
: this(typeof(DefaultCoreConfig)) | ||
{ | ||
} | ||
|
||
public AspNetCoreBenchmarkAttribute(Type configType) | ||
: this(configType, typeof(DefaultCoreValidationConfig)) | ||
{ | ||
} | ||
|
||
public AspNetCoreBenchmarkAttribute(Type configType, Type validationConfigType) | ||
{ | ||
ConfigTypes = new Dictionary<string, Type>() | ||
{ | ||
{ NamedConfiguration.Default, typeof(DefaultCoreConfig) }, | ||
{ NamedConfiguration.Validation, typeof(DefaultCoreValidationConfig) }, | ||
{ NamedConfiguration.Profile, typeof(DefaultCoreProfileConfig) }, | ||
{ NamedConfiguration.Debug, typeof(DefaultCoreDebugConfig) }, | ||
{ NamedConfiguration.PerfLab, typeof(DefaultCorePerfLabConfig) }, | ||
}; | ||
|
||
if (configType != null) | ||
{ | ||
ConfigTypes[NamedConfiguration.Default] = configType; | ||
} | ||
|
||
if (validationConfigType != null) | ||
{ | ||
ConfigTypes[NamedConfiguration.Validation] = validationConfigType; | ||
} | ||
} | ||
|
||
public IConfig Config | ||
{ | ||
get | ||
{ | ||
if (!ConfigTypes.TryGetValue(ConfigName ?? NamedConfiguration.Default, out var configType)) | ||
{ | ||
var message = $"Could not find a configuration matching {ConfigName}. " + | ||
$"Known configurations: {string.Join(", ", ConfigTypes.Keys)}"; | ||
throw new InvalidOperationException(message); | ||
} | ||
|
||
return (IConfig)Activator.CreateInstance(configType, Array.Empty<object>()); | ||
} | ||
} | ||
|
||
public Dictionary<string, Type> ConfigTypes { get; } | ||
|
||
public static string ConfigName { get; set; } = NamedConfiguration.Default; | ||
|
||
public static class NamedConfiguration | ||
{ | ||
public static readonly string Default = "default"; | ||
public static readonly string Validation = "validation"; | ||
public static readonly string Profile = "profile"; | ||
public static readonly string Debug = "debug"; | ||
public static readonly string PerfLab = "perflab"; | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/libraries/Common/src/Extensions/BenchmarkRunner/DefaultCoreConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using BenchmarkDotNet.Engines; | ||
using BenchmarkDotNet.Exporters; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Toolchains.CsProj; | ||
using BenchmarkDotNet.Toolchains.DotNetCli; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
internal class DefaultCoreConfig : ManualConfig | ||
{ | ||
public DefaultCoreConfig() | ||
{ | ||
Add(ConsoleLogger.Default); | ||
Add(MarkdownExporter.GitHub); | ||
|
||
Add(MemoryDiagnoser.Default); | ||
Add(StatisticColumn.OperationsPerSecond); | ||
Add(DefaultColumnProviders.Instance); | ||
|
||
Add(JitOptimizationsValidator.FailOnError); | ||
|
||
Add(Job.Core | ||
#if NETCOREAPP2_1 | ||
.With(CsProjCoreToolchain.From(NetCoreAppSettings.NetCoreApp21)) | ||
#elif NETCOREAPP3_0 | ||
.With(CsProjCoreToolchain.From(new NetCoreAppSettings("netcoreapp3.0", null, ".NET Core 3.0"))) | ||
#elif NETCOREAPP3_1 | ||
.With(CsProjCoreToolchain.From(new NetCoreAppSettings("netcoreapp3.1", null, ".NET Core 3.1"))) | ||
#elif NETCOREAPP5_0 | ||
.With(CsProjCoreToolchain.From(new NetCoreAppSettings("netcoreapp5.0", null, ".NET Core 5.0"))) | ||
#else | ||
#error Target frameworks need to be updated. | ||
#endif | ||
.With(new GcMode { Server = true }) | ||
.With(RunStrategy.Throughput)); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/libraries/Common/src/Extensions/BenchmarkRunner/DefaultCoreDebugConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Engines; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
internal class DefaultCoreDebugConfig : ManualConfig | ||
{ | ||
public DefaultCoreDebugConfig() | ||
{ | ||
Add(ConsoleLogger.Default); | ||
Add(JitOptimizationsValidator.DontFailOnError); | ||
|
||
Add(Job.InProcess | ||
.With(RunStrategy.Throughput)); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/libraries/Common/src/Extensions/BenchmarkRunner/DefaultCorePerfLabConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using BenchmarkDotNet.Engines; | ||
using BenchmarkDotNet.Exporters; | ||
using BenchmarkDotNet.Exporters.Csv; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
internal class DefaultCorePerfLabConfig : ManualConfig | ||
{ | ||
public DefaultCorePerfLabConfig() | ||
{ | ||
Add(ConsoleLogger.Default); | ||
|
||
Add(MemoryDiagnoser.Default); | ||
Add(StatisticColumn.OperationsPerSecond); | ||
Add(new ParamsSummaryColumn()); | ||
Add(DefaultColumnProviders.Statistics, DefaultColumnProviders.Diagnosers, DefaultColumnProviders.Target); | ||
|
||
// TODO: When upgrading to BDN 0.11.1, use Add(DefaultColumnProviders.Descriptor); | ||
// DefaultColumnProviders.Target is deprecated | ||
|
||
Add(JitOptimizationsValidator.FailOnError); | ||
|
||
Add(Job.InProcess | ||
.With(RunStrategy.Throughput)); | ||
|
||
Add(MarkdownExporter.GitHub); | ||
|
||
Add(new CsvExporter( | ||
CsvSeparator.Comma, | ||
new Reports.SummaryStyle | ||
{ | ||
PrintUnitsInHeader = true, | ||
PrintUnitsInContent = false, | ||
TimeUnit = Horology.TimeUnit.Microsecond, | ||
SizeUnit = SizeUnit.KB | ||
})); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/libraries/Common/src/Extensions/BenchmarkRunner/DefaultCoreProfileConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using BenchmarkDotNet.Engines; | ||
using BenchmarkDotNet.Exporters; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
internal class DefaultCoreProfileConfig : ManualConfig | ||
{ | ||
public DefaultCoreProfileConfig() | ||
{ | ||
Add(ConsoleLogger.Default); | ||
Add(MarkdownExporter.GitHub); | ||
|
||
Add(MemoryDiagnoser.Default); | ||
Add(StatisticColumn.OperationsPerSecond); | ||
Add(DefaultColumnProviders.Instance); | ||
|
||
Add(JitOptimizationsValidator.FailOnError); | ||
|
||
Add(Job.InProcess | ||
.With(RunStrategy.Throughput)); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/Common/src/Extensions/BenchmarkRunner/DefaultCoreValidationConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Toolchains.InProcess; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
internal class DefaultCoreValidationConfig : ManualConfig | ||
{ | ||
public DefaultCoreValidationConfig() | ||
{ | ||
Add(ConsoleLogger.Default); | ||
|
||
Add(Job.Dry.With(InProcessToolchain.Instance)); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...Common/src/Extensions/BenchmarkRunner/Microsoft.AspNetCore.BenchmarkRunner.Sources.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project> | ||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | ||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> | ||
|
||
<Target Name="Compile" /> | ||
<Target Name="CopyFilesToOutputDirectory" /> | ||
</Project> |
16 changes: 16 additions & 0 deletions
16
src/libraries/Common/src/Extensions/BenchmarkRunner/ParameterizedJobConfigAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)] | ||
internal class ParameterizedJobConfigAttribute: AspNetCoreBenchmarkAttribute | ||
{ | ||
public ParameterizedJobConfigAttribute(Type configType) : base(configType) | ||
{ | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/libraries/Common/src/Extensions/BenchmarkRunner/ParamsDisplayInfoColumn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Reports; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
public class ParamsSummaryColumn : IColumn | ||
{ | ||
public string Id => nameof(ParamsSummaryColumn); | ||
public string ColumnName { get; } = "Params"; | ||
public bool IsDefault(Summary summary, Benchmark benchmark) => false; | ||
public string GetValue(Summary summary, Benchmark benchmark) => benchmark.Parameters.DisplayInfo; | ||
public bool IsAvailable(Summary summary) => true; | ||
public bool AlwaysShow => true; | ||
public ColumnCategory Category => ColumnCategory.Params; | ||
public int PriorityInCategory => 0; | ||
public override string ToString() => ColumnName; | ||
public bool IsNumeric => false; | ||
public UnitType UnitType => UnitType.Dimensionless; | ||
public string GetValue(Summary summary, Benchmark benchmark, ISummaryStyle style) => GetValue(summary, benchmark); | ||
public string Legend => $"Summary of all parameter values"; | ||
} | ||
} |
Oops, something went wrong.