Skip to content

Commit

Permalink
Bump .editorconfig & use file scoped namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Nov 9, 2021
1 parent d134fef commit add335b
Show file tree
Hide file tree
Showing 181 changed files with 17,574 additions and 17,753 deletions.
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version: 3.0.0 (Using https://semver.org/)
# Updated: 2021-08-09
# Version: 4.0.0 (Using https://semver.org/)
# Updated: 2021-10-12
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
Expand Down Expand Up @@ -167,6 +167,8 @@ dotnet_diagnostic.IDE0063.severity = suggestion
csharp_using_directive_placement = inside_namespace:warning
# Modifier preferences
csharp_prefer_static_local_function = true:warning
# Undocumented
csharp_style_namespace_declarations = file_scoped:warning

##########################################
# Unnecessary Code Rules
Expand Down
129 changes: 64 additions & 65 deletions Benchmarks/Boxed.Mapping.Benchmark/MapArrayBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,81 +1,80 @@
namespace Boxed.Mapping.Benchmark
namespace Boxed.Mapping.Benchmark;

using System;
using System.Globalization;
using AutoMapper;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Boxed.Mapping.Benchmark.Mapping;
using Boxed.Mapping.Benchmark.Models;

[KeepBenchmarkFiles]
[MemoryDiagnoser]
[MinColumn]
[MaxColumn]
[HtmlExporter]
[CsvMeasurementsExporter]
[RPlotExporter]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net50)]
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
[SimpleJob(RuntimeMoniker.Net472)]
public class MapArrayBenchmark
{
using System;
using System.Globalization;
using AutoMapper;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Boxed.Mapping.Benchmark.Mapping;
using Boxed.Mapping.Benchmark.Models;
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private MapFrom[] mapFrom = default!;

[KeepBenchmarkFiles]
[MemoryDiagnoser]
[MinColumn]
[MaxColumn]
[HtmlExporter]
[CsvMeasurementsExporter]
[RPlotExporter]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net50)]
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
[SimpleJob(RuntimeMoniker.Net472)]
public class MapArrayBenchmark
public MapArrayBenchmark()
{
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private MapFrom[] mapFrom = default!;

public MapArrayBenchmark()
{
this.automapper = AutomapperConfiguration.CreateMapper();
this.boilerplateMapper = new BoxedMapper();
this.random = new Random();
}
this.automapper = AutomapperConfiguration.CreateMapper();
this.boilerplateMapper = new BoxedMapper();
this.random = new Random();
}

[GlobalSetup]
public void GlobalSetup()
[GlobalSetup]
public void GlobalSetup()
{
this.mapFrom = new MapFrom[100];
for (var i = 0; i < this.mapFrom.Length; ++i)
{
this.mapFrom = new MapFrom[100];
for (var i = 0; i < this.mapFrom.Length; ++i)
this.mapFrom[i] = new MapFrom()
{
this.mapFrom[i] = new MapFrom()
{
#pragma warning disable CA5394 // Do not use insecure randomness
BooleanFrom = this.random.NextDouble() > 0.5D,
DateTimeOffsetFrom = DateTimeOffset.UtcNow,
IntegerFrom = this.random.Next(),
LongFrom = this.random.Next(),
StringFrom = this.random.Next().ToString(CultureInfo.InvariantCulture),
BooleanFrom = this.random.NextDouble() > 0.5D,
DateTimeOffsetFrom = DateTimeOffset.UtcNow,
IntegerFrom = this.random.Next(),
LongFrom = this.random.Next(),
StringFrom = this.random.Next().ToString(CultureInfo.InvariantCulture),
#pragma warning restore CA5394 // Do not use insecure randomness
};
}
};
}
}

[Benchmark(Baseline = true)]
public MapTo[] Baseline()
[Benchmark(Baseline = true)]
public MapTo[] Baseline()
{
var destination = new MapTo[this.mapFrom.Length];
for (var i = 0; i < this.mapFrom.Length; ++i)
{
var destination = new MapTo[this.mapFrom.Length];
for (var i = 0; i < this.mapFrom.Length; ++i)
var item = this.mapFrom[i];
destination[i] = new MapTo()
{
var item = this.mapFrom[i];
destination[i] = new MapTo()
{
BooleanTo = item.BooleanFrom,
DateTimeOffsetTo = item.DateTimeOffsetFrom,
IntegerTo = item.IntegerFrom,
LongTo = item.LongFrom,
StringTo = item.StringFrom,
};
}

return destination;
BooleanTo = item.BooleanFrom,
DateTimeOffsetTo = item.DateTimeOffsetFrom,
IntegerTo = item.IntegerFrom,
LongTo = item.LongFrom,
StringTo = item.StringFrom,
};
}

[Benchmark]
public MapTo[] BoxedMapper() => this.boilerplateMapper.MapArray(this.mapFrom);

[Benchmark]
public MapTo[] Automapper() => this.automapper.Map<MapTo[]>(this.mapFrom);
return destination;
}

[Benchmark]
public MapTo[] BoxedMapper() => this.boilerplateMapper.MapArray(this.mapFrom);

[Benchmark]
public MapTo[] Automapper() => this.automapper.Map<MapTo[]>(this.mapFrom);
}
132 changes: 65 additions & 67 deletions Benchmarks/Boxed.Mapping.Benchmark/MapListBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,84 +1,82 @@
namespace Boxed.Mapping.Benchmark
{
using System;
using System.Collections.Generic;
using System.Globalization;
using AutoMapper;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Boxed.Mapping.Benchmark.Mapping;
using Boxed.Mapping.Benchmark.Models;
namespace Boxed.Mapping.Benchmark;

using System;
using System.Collections.Generic;
using System.Globalization;
using AutoMapper;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Boxed.Mapping.Benchmark.Mapping;
using Boxed.Mapping.Benchmark.Models;

#pragma warning disable CA1002 // Do not expose generic lists
[KeepBenchmarkFiles]
[MemoryDiagnoser]
[MinColumn]
[MaxColumn]
[HtmlExporter]
[CsvMeasurementsExporter]
[RPlotExporter]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net50)]
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
[SimpleJob(RuntimeMoniker.Net472)]
public class MapListBenchmark
{
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private List<MapFrom> mapFrom = default!;
[KeepBenchmarkFiles]
[MemoryDiagnoser]
[MinColumn]
[MaxColumn]
[HtmlExporter]
[CsvMeasurementsExporter]
[RPlotExporter]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net50)]
[SimpleJob(RuntimeMoniker.NetCoreApp30)]
[SimpleJob(RuntimeMoniker.Net472)]
public class MapListBenchmark
{
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private List<MapFrom> mapFrom = default!;

public MapListBenchmark()
{
this.automapper = AutomapperConfiguration.CreateMapper();
this.boilerplateMapper = new BoxedMapper();
this.random = new Random();
}
public MapListBenchmark()
{
this.automapper = AutomapperConfiguration.CreateMapper();
this.boilerplateMapper = new BoxedMapper();
this.random = new Random();
}

[GlobalSetup]
public void GlobalSetup()
[GlobalSetup]
public void GlobalSetup()
{
this.mapFrom = new List<MapFrom>();
for (var i = 0; i < 100; ++i)
{
this.mapFrom = new List<MapFrom>();
for (var i = 0; i < 100; ++i)
{
this.mapFrom.Add(
new MapFrom()
{
this.mapFrom.Add(
new MapFrom()
{
#pragma warning disable CA5394 // Do not use insecure randomness
BooleanFrom = this.random.NextDouble() > 0.5D,
DateTimeOffsetFrom = DateTimeOffset.UtcNow,
IntegerFrom = this.random.Next(),
LongFrom = this.random.Next(),
StringFrom = this.random.Next().ToString(CultureInfo.InvariantCulture),
DateTimeOffsetFrom = DateTimeOffset.UtcNow,
IntegerFrom = this.random.Next(),
LongFrom = this.random.Next(),
StringFrom = this.random.Next().ToString(CultureInfo.InvariantCulture),
#pragma warning restore CA5394 // Do not use insecure randomness
});
}
}
}

[Benchmark(Baseline = true)]
public List<MapTo> Baseline()
[Benchmark(Baseline = true)]
public List<MapTo> Baseline()
{
var destination = new List<MapTo>(this.mapFrom.Count);
foreach (var item in this.mapFrom)
{
var destination = new List<MapTo>(this.mapFrom.Count);
foreach (var item in this.mapFrom)
destination.Add(new MapTo()
{
destination.Add(new MapTo()
{
BooleanTo = item.BooleanFrom,
DateTimeOffsetTo = item.DateTimeOffsetFrom,
IntegerTo = item.IntegerFrom,
LongTo = item.LongFrom,
StringTo = item.StringFrom,
});
}

return destination;
BooleanTo = item.BooleanFrom,
DateTimeOffsetTo = item.DateTimeOffsetFrom,
IntegerTo = item.IntegerFrom,
LongTo = item.LongFrom,
StringTo = item.StringFrom,
});
}

[Benchmark]
public List<MapTo> BoxedMapper() => this.boilerplateMapper.MapList(this.mapFrom);

[Benchmark]
public List<MapTo> Automapper() => this.automapper.Map<List<MapTo>>(this.mapFrom);
return destination;
}
#pragma warning restore CA1002 // Do not expose generic lists

[Benchmark]
public List<MapTo> BoxedMapper() => this.boilerplateMapper.MapList(this.mapFrom);

[Benchmark]
public List<MapTo> Automapper() => this.automapper.Map<List<MapTo>>(this.mapFrom);
}
Loading

0 comments on commit add335b

Please sign in to comment.