Skip to content

Commit e3ffd34

Browse files
authored
Merge pull request #32912 from maryamariyan/primitives-total
Extensions consolidation
2 parents 71deb1e + 3df8292 commit e3ffd34

File tree

744 files changed

+76016
-0
lines changed

Some content is hidden

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

744 files changed

+76016
-0
lines changed

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<PatchVersion>0</PatchVersion>
99
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
1010
<PreReleaseVersionIteration>2</PreReleaseVersionIteration>
11+
<PreReleaseVersionIteration Condition="$(MSBuildProjectName.StartsWith('Microsoft.Extensions.'))">$(PreReleaseVersionIteration)-runtime</PreReleaseVersionIteration>
1112
<!-- Set assembly version to align with major and minor version,
1213
as for the patches and revisions should be manually updated per assembly if it is serviced. -->
1314
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>

src/libraries/Common/src/Extensions/ActivatorUtilities/ActivatorUtilities.cs

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
#if ActivatorUtilities_In_DependencyInjection
8+
namespace Microsoft.Extensions.DependencyInjection
9+
#else
10+
namespace Microsoft.Extensions.Internal
11+
#endif
12+
{
13+
/// <summary>
14+
/// Marks the constructor to be used when activating type using <see cref="ActivatorUtilities"/>.
15+
/// </summary>
16+
17+
#if ActivatorUtilities_In_DependencyInjection
18+
public
19+
#else
20+
// Do not take a dependency on this class unless you are explicitly trying to avoid taking a
21+
// dependency on Microsoft.AspNetCore.DependencyInjection.Abstractions.
22+
internal
23+
#endif
24+
class ActivatorUtilitiesConstructorAttribute: Attribute
25+
{
26+
}
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project>
2+
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
3+
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
4+
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildThisFileDirectory)..\ParameterDefaultValue\ParameterDefaultValue.cs">
7+
<Pack>true</Pack>
8+
<PackagePath>$(ContentTargetFolders)\cs\netstandard1.0\</PackagePath>
9+
</Compile>
10+
</ItemGroup>
11+
12+
<Target Name="Compile" />
13+
<Target Name="CopyFilesToOutputDirectory" />
14+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
#if ActivatorUtilities_In_DependencyInjection
8+
namespace Microsoft.Extensions.DependencyInjection
9+
#else
10+
namespace Microsoft.Extensions.Internal
11+
#endif
12+
{
13+
14+
/// <summary>
15+
/// The result of <see cref="ActivatorUtilities.CreateFactory(Type, Type[])"/>.
16+
/// </summary>
17+
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> to get service arguments from.</param>
18+
/// <param name="arguments">Additional constructor arguments.</param>
19+
/// <returns>The instantiated type.</returns>
20+
#if ActivatorUtilities_In_DependencyInjection
21+
public
22+
#else
23+
internal
24+
#endif
25+
delegate object ObjectFactory(IServiceProvider serviceProvider, object[] arguments);
26+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using BenchmarkDotNet.Configs;
8+
9+
namespace BenchmarkDotNet.Attributes
10+
{
11+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
12+
internal class AspNetCoreBenchmarkAttribute : Attribute, IConfigSource
13+
{
14+
public AspNetCoreBenchmarkAttribute()
15+
: this(typeof(DefaultCoreConfig))
16+
{
17+
}
18+
19+
public AspNetCoreBenchmarkAttribute(Type configType)
20+
: this(configType, typeof(DefaultCoreValidationConfig))
21+
{
22+
}
23+
24+
public AspNetCoreBenchmarkAttribute(Type configType, Type validationConfigType)
25+
{
26+
ConfigTypes = new Dictionary<string, Type>()
27+
{
28+
{ NamedConfiguration.Default, typeof(DefaultCoreConfig) },
29+
{ NamedConfiguration.Validation, typeof(DefaultCoreValidationConfig) },
30+
{ NamedConfiguration.Profile, typeof(DefaultCoreProfileConfig) },
31+
{ NamedConfiguration.Debug, typeof(DefaultCoreDebugConfig) },
32+
{ NamedConfiguration.PerfLab, typeof(DefaultCorePerfLabConfig) },
33+
};
34+
35+
if (configType != null)
36+
{
37+
ConfigTypes[NamedConfiguration.Default] = configType;
38+
}
39+
40+
if (validationConfigType != null)
41+
{
42+
ConfigTypes[NamedConfiguration.Validation] = validationConfigType;
43+
}
44+
}
45+
46+
public IConfig Config
47+
{
48+
get
49+
{
50+
if (!ConfigTypes.TryGetValue(ConfigName ?? NamedConfiguration.Default, out var configType))
51+
{
52+
var message = $"Could not find a configuration matching {ConfigName}. " +
53+
$"Known configurations: {string.Join(", ", ConfigTypes.Keys)}";
54+
throw new InvalidOperationException(message);
55+
}
56+
57+
return (IConfig)Activator.CreateInstance(configType, Array.Empty<object>());
58+
}
59+
}
60+
61+
public Dictionary<string, Type> ConfigTypes { get; }
62+
63+
public static string ConfigName { get; set; } = NamedConfiguration.Default;
64+
65+
public static class NamedConfiguration
66+
{
67+
public static readonly string Default = "default";
68+
public static readonly string Validation = "validation";
69+
public static readonly string Profile = "profile";
70+
public static readonly string Debug = "debug";
71+
public static readonly string PerfLab = "perflab";
72+
}
73+
}
74+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using BenchmarkDotNet.Columns;
6+
using BenchmarkDotNet.Configs;
7+
using BenchmarkDotNet.Diagnosers;
8+
using BenchmarkDotNet.Engines;
9+
using BenchmarkDotNet.Exporters;
10+
using BenchmarkDotNet.Jobs;
11+
using BenchmarkDotNet.Loggers;
12+
using BenchmarkDotNet.Toolchains.CsProj;
13+
using BenchmarkDotNet.Toolchains.DotNetCli;
14+
using BenchmarkDotNet.Validators;
15+
16+
namespace BenchmarkDotNet.Attributes
17+
{
18+
internal class DefaultCoreConfig : ManualConfig
19+
{
20+
public DefaultCoreConfig()
21+
{
22+
Add(ConsoleLogger.Default);
23+
Add(MarkdownExporter.GitHub);
24+
25+
Add(MemoryDiagnoser.Default);
26+
Add(StatisticColumn.OperationsPerSecond);
27+
Add(DefaultColumnProviders.Instance);
28+
29+
Add(JitOptimizationsValidator.FailOnError);
30+
31+
Add(Job.Core
32+
#if NETCOREAPP2_1
33+
.With(CsProjCoreToolchain.From(NetCoreAppSettings.NetCoreApp21))
34+
#elif NETCOREAPP3_0
35+
.With(CsProjCoreToolchain.From(new NetCoreAppSettings("netcoreapp3.0", null, ".NET Core 3.0")))
36+
#elif NETCOREAPP3_1
37+
.With(CsProjCoreToolchain.From(new NetCoreAppSettings("netcoreapp3.1", null, ".NET Core 3.1")))
38+
#elif NETCOREAPP5_0
39+
.With(CsProjCoreToolchain.From(new NetCoreAppSettings("netcoreapp5.0", null, ".NET Core 5.0")))
40+
#else
41+
#error Target frameworks need to be updated.
42+
#endif
43+
.With(new GcMode { Server = true })
44+
.With(RunStrategy.Throughput));
45+
}
46+
}
47+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using BenchmarkDotNet.Configs;
6+
using BenchmarkDotNet.Engines;
7+
using BenchmarkDotNet.Jobs;
8+
using BenchmarkDotNet.Loggers;
9+
using BenchmarkDotNet.Validators;
10+
11+
namespace BenchmarkDotNet.Attributes
12+
{
13+
internal class DefaultCoreDebugConfig : ManualConfig
14+
{
15+
public DefaultCoreDebugConfig()
16+
{
17+
Add(ConsoleLogger.Default);
18+
Add(JitOptimizationsValidator.DontFailOnError);
19+
20+
Add(Job.InProcess
21+
.With(RunStrategy.Throughput));
22+
}
23+
}
24+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using BenchmarkDotNet.Columns;
6+
using BenchmarkDotNet.Configs;
7+
using BenchmarkDotNet.Diagnosers;
8+
using BenchmarkDotNet.Engines;
9+
using BenchmarkDotNet.Exporters;
10+
using BenchmarkDotNet.Exporters.Csv;
11+
using BenchmarkDotNet.Jobs;
12+
using BenchmarkDotNet.Loggers;
13+
using BenchmarkDotNet.Validators;
14+
15+
namespace BenchmarkDotNet.Attributes
16+
{
17+
internal class DefaultCorePerfLabConfig : ManualConfig
18+
{
19+
public DefaultCorePerfLabConfig()
20+
{
21+
Add(ConsoleLogger.Default);
22+
23+
Add(MemoryDiagnoser.Default);
24+
Add(StatisticColumn.OperationsPerSecond);
25+
Add(new ParamsSummaryColumn());
26+
Add(DefaultColumnProviders.Statistics, DefaultColumnProviders.Diagnosers, DefaultColumnProviders.Target);
27+
28+
// TODO: When upgrading to BDN 0.11.1, use Add(DefaultColumnProviders.Descriptor);
29+
// DefaultColumnProviders.Target is deprecated
30+
31+
Add(JitOptimizationsValidator.FailOnError);
32+
33+
Add(Job.InProcess
34+
.With(RunStrategy.Throughput));
35+
36+
Add(MarkdownExporter.GitHub);
37+
38+
Add(new CsvExporter(
39+
CsvSeparator.Comma,
40+
new Reports.SummaryStyle
41+
{
42+
PrintUnitsInHeader = true,
43+
PrintUnitsInContent = false,
44+
TimeUnit = Horology.TimeUnit.Microsecond,
45+
SizeUnit = SizeUnit.KB
46+
}));
47+
}
48+
}
49+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// See the LICENSE file in the project root for more information.
4+
5+
using BenchmarkDotNet.Columns;
6+
using BenchmarkDotNet.Configs;
7+
using BenchmarkDotNet.Diagnosers;
8+
using BenchmarkDotNet.Engines;
9+
using BenchmarkDotNet.Exporters;
10+
using BenchmarkDotNet.Jobs;
11+
using BenchmarkDotNet.Loggers;
12+
using BenchmarkDotNet.Validators;
13+
14+
namespace BenchmarkDotNet.Attributes
15+
{
16+
internal class DefaultCoreProfileConfig : ManualConfig
17+
{
18+
public DefaultCoreProfileConfig()
19+
{
20+
Add(ConsoleLogger.Default);
21+
Add(MarkdownExporter.GitHub);
22+
23+
Add(MemoryDiagnoser.Default);
24+
Add(StatisticColumn.OperationsPerSecond);
25+
Add(DefaultColumnProviders.Instance);
26+
27+
Add(JitOptimizationsValidator.FailOnError);
28+
29+
Add(Job.InProcess
30+
.With(RunStrategy.Throughput));
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)