Skip to content

Commit

Permalink
Merge pull request #32912 from maryamariyan/primitives-total
Browse files Browse the repository at this point in the history
Extensions consolidation
  • Loading branch information
maryamariyan authored Mar 2, 2020
2 parents 71deb1e + 3df8292 commit e3ffd34
Show file tree
Hide file tree
Showing 744 changed files with 76,016 additions and 0 deletions.
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PatchVersion>0</PatchVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<PreReleaseVersionIteration>2</PreReleaseVersionIteration>
<PreReleaseVersionIteration Condition="$(MSBuildProjectName.StartsWith('Microsoft.Extensions.'))">$(PreReleaseVersionIteration)-runtime</PreReleaseVersionIteration>
<!-- Set assembly version to align with major and minor version,
as for the patches and revisions should be manually updated per assembly if it is serviced. -->
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
Expand Down

Large diffs are not rendered by default.

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
{
}
}
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>
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);
}
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";
}
}
}
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));
}
}
}
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));
}
}
}
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
}));
}
}
}
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));
}
}
}
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));
}
}
}
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>
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)
{
}
}
}
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";
}
}
Loading

0 comments on commit e3ffd34

Please sign in to comment.