Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
43cbdab
Fix stylecop warnings in the test project
brianpopow Jan 21, 2020
38454f8
Use using declarations to reduce nesting
brianpopow Jan 22, 2020
bb42df5
Merge remote-tracking branch 'upstream/master' into feature/stylecopT…
brianpopow Jan 22, 2020
6c40593
Remove regions
brianpopow Jan 23, 2020
f897ab6
Change WithTestPatternImageAttribute to WithTestPatternImagesAttribute
brianpopow Jan 23, 2020
94dc54b
Rename method names again to be the same as in the reference implemen…
brianpopow Jan 23, 2020
715de4c
Defining the tmp vars in a single line again
brianpopow Jan 23, 2020
8a6797c
Move ITestImageProvider to a separate file
brianpopow Jan 23, 2020
d59ca98
Revert comment as it was before, add exception for SA1115
brianpopow Jan 23, 2020
32bc422
Merge remote-tracking branch 'upstream/master' into feature/stylecopT…
brianpopow Jan 30, 2020
076a2bc
Update external for the changed test ruleset
brianpopow Jan 30, 2020
6f0e6e9
Fix some leftover stylecop warnings
brianpopow Jan 30, 2020
9f181a3
Change InternalsVisibleTo from SixLabors.ImageSharp.Sandbox46 to Imag…
brianpopow Jan 30, 2020
5ff7bb7
Revert "Change InternalsVisibleTo from SixLabors.ImageSharp.Sandbox46…
brianpopow Jan 31, 2020
0bce7af
Remove including tests into the profiling sandbox
brianpopow Jan 31, 2020
2c7e253
Merge branch 'master' into feature/stylecopTests
brianpopow Jan 31, 2020
15a7a55
Revert `using` declaration changes for until we establish guidelines.
JimBobSquarePants Feb 2, 2020
1f3311b
Add more rule exemptions and prevent blanket using recommendations
JimBobSquarePants Feb 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" IsImplicitlyDefined="true" />
<!--TODO: Enable this once tests Stylecop issues are fixed-->
<!--<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />-->
<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)shared-infrastructure\stylecop.json" />
<!--NuGet package icon source-->
<None Include="$(MSBuildThisFileDirectory)shared-infrastructure\branding\icons\imagesharp\sixlabors.imagesharp.128.png" Pack="true" PackagePath="\icon.png" />
Expand Down
2 changes: 1 addition & 1 deletion shared-infrastructure
5 changes: 1 addition & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
</PropertyGroup>

<ItemGroup>
<!--TODO: Delete this once tests Stylecop issues are fixed-->
<PackageReference Include="StyleCop.Analyzers" IsImplicitlyDefined="true" />

<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKeyToken=null" />
<InternalsVisibleTo Include="ImageSharp.Benchmarks" />
<InternalsVisibleTo Include="SixLabors.ImageSharp.Sandbox46" />
<InternalsVisibleTo Include="SixLabors.ImageSharp.Tests" />
<InternalsVisibleTo Include="ImageSharp.Tests.ProfilingSandbox" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this your breaking change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have added this because i was getting more than 2k errors of Error CS0122 '...' is inaccessible due to its protection level

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because you're including all the files from the test project in the sandbox.

https://github.com/SixLabors/ImageSharp/pull/1090/files#diff-791cc76ca5e2665ba784771043fd9123R17

We don't do that anymore. The sandbox project simply references the test one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because you're including all the files from the test project in the sandbox.

https://github.com/SixLabors/ImageSharp/pull/1090/files#diff-791cc76ca5e2665ba784771043fd9123R17

We don't do that anymore. The sandbox project simply references the test one.

great, thank you! I was not aware of that. I have the removed the tests from the profiling sandbox, now it work works. See: commit: 0bce7af

</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class ParallelHelper
/// <param name="body">The method body defining the iteration logic on a single <see cref="RowInterval"/>.</param>
public static void IterateRows(Rectangle rectangle, Configuration configuration, Action<RowInterval> body)
{
ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);
var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration);

IterateRows(rectangle, parallelSettings, body);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry()
else
{
// The type is not know, so the values need be read
var values = new double[channelCount][];
double[][] values = new double[channelCount][];
for (int i = 0; i < channelCount; i++)
{
values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() };
Expand Down Expand Up @@ -208,7 +208,7 @@ public IccCurveTagDataEntry ReadCurveTagDataEntry()
return new IccCurveTagDataEntry(this.ReadUFix8());
}

var cdata = new float[pointCount];
float[] cdata = new float[pointCount];
for (int i = 0; i < pointCount; i++)
{
cdata[i] = this.ReadUInt16() / 65535f;
Expand Down Expand Up @@ -264,7 +264,7 @@ public IccLut16TagDataEntry ReadLut16TagDataEntry()

// Input LUT
var inValues = new IccLut[inChCount];
var gridPointCount = new byte[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
inValues[i] = this.ReadLut16(inTableCount);
Expand Down Expand Up @@ -299,7 +299,7 @@ public IccLut8TagDataEntry ReadLut8TagDataEntry()

// Input LUT
var inValues = new IccLut[inChCount];
var gridPointCount = new byte[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
inValues[i] = this.ReadLut8();
Expand Down Expand Up @@ -464,8 +464,8 @@ public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntr
var text = new IccLocalizedString[recordCount];

var culture = new CultureInfo[recordCount];
var length = new uint[recordCount];
var offset = new uint[recordCount];
uint[] length = new uint[recordCount];
uint[] offset = new uint[recordCount];

for (int i = 0; i < recordCount; i++)
{
Expand Down Expand Up @@ -627,7 +627,7 @@ public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry()
ushort channelCount = this.ReadUInt16();
ushort measurementCount = this.ReadUInt16();

var offset = new uint[measurementCount];
uint[] offset = new uint[measurementCount];
for (int i = 0; i < measurementCount; i++)
{
offset[i] = this.ReadUInt32();
Expand All @@ -651,7 +651,7 @@ public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry()
public IccFix16ArrayTagDataEntry ReadFix16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new float[count];
float[] arrayData = new float[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadFix16() / 256f;
Expand Down Expand Up @@ -687,7 +687,7 @@ public IccTextTagDataEntry ReadTextTagDataEntry(uint size)
public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new float[count];
float[] arrayData = new float[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUFix16();
Expand All @@ -704,7 +704,7 @@ public IccUFix16ArrayTagDataEntry ReadUFix16ArrayTagDataEntry(uint size)
public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 2;
var arrayData = new ushort[count];
ushort[] arrayData = new ushort[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt16();
Expand All @@ -721,7 +721,7 @@ public IccUInt16ArrayTagDataEntry ReadUInt16ArrayTagDataEntry(uint size)
public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 4;
var arrayData = new uint[count];
uint[] arrayData = new uint[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt32();
Expand All @@ -738,7 +738,7 @@ public IccUInt32ArrayTagDataEntry ReadUInt32ArrayTagDataEntry(uint size)
public IccUInt64ArrayTagDataEntry ReadUInt64ArrayTagDataEntry(uint size)
{
uint count = (size - 8) / 8;
var arrayData = new ulong[count];
ulong[] arrayData = new ulong[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadUInt64();
Expand Down Expand Up @@ -878,14 +878,14 @@ public IccScreeningTagDataEntry ReadScreeningTagDataEntry()
public IccUcrBgTagDataEntry ReadUcrBgTagDataEntry(uint size)
{
uint ucrCount = this.ReadUInt32();
var ucrCurve = new ushort[ucrCount];
ushort[] ucrCurve = new ushort[ucrCount];
for (int i = 0; i < ucrCurve.Length; i++)
{
ucrCurve[i] = this.ReadUInt16();
}

uint bgCount = this.ReadUInt32();
var bgCurve = new ushort[bgCount];
ushort[] bgCurve = new ushort[bgCount];
for (int i = 0; i < bgCurve.Length; i++)
{
bgCurve[i] = this.ReadUInt16();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Numerics;
using System.Runtime.CompilerServices;

namespace SixLabors.ImageSharp.Metadata.Profiles.Icc
{
Expand Down Expand Up @@ -53,4 +54,4 @@ public bool Equals(IccXyzTagDataEntry other)
return this.Equals((IccTagDataEntry)other);
}
}
}
}
10 changes: 5 additions & 5 deletions src/ImageSharp/Primitives/ColorMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public bool IsIdentity
/// <returns>The resulting matrix.</returns>
public static ColorMatrix operator +(ColorMatrix value1, ColorMatrix value2)
{
ColorMatrix m;
var m = default(ColorMatrix);
Comment thread
JimBobSquarePants marked this conversation as resolved.

m.M11 = value1.M11 + value2.M11;
m.M12 = value1.M12 + value2.M12;
Expand Down Expand Up @@ -238,7 +238,7 @@ public bool IsIdentity
/// <returns>The result of the subtraction.</returns>
public static ColorMatrix operator -(ColorMatrix value1, ColorMatrix value2)
{
ColorMatrix m;
var m = default(ColorMatrix);

m.M11 = value1.M11 - value2.M11;
m.M12 = value1.M12 - value2.M12;
Expand Down Expand Up @@ -271,7 +271,7 @@ public bool IsIdentity
/// <returns>The negated matrix.</returns>
public static ColorMatrix operator -(ColorMatrix value)
{
ColorMatrix m;
var m = default(ColorMatrix);

m.M11 = -value.M11;
m.M12 = -value.M12;
Expand Down Expand Up @@ -305,7 +305,7 @@ public bool IsIdentity
/// <returns>The result of the multiplication.</returns>
public static ColorMatrix operator *(ColorMatrix value1, ColorMatrix value2)
{
ColorMatrix m;
var m = default(ColorMatrix);

// First row
m.M11 = (value1.M11 * value2.M11) + (value1.M12 * value2.M21) + (value1.M13 * value2.M31) + (value1.M14 * value2.M41);
Expand Down Expand Up @@ -348,7 +348,7 @@ public bool IsIdentity
/// <returns>The scaled matrix.</returns>
public static ColorMatrix operator *(ColorMatrix value1, float value2)
{
ColorMatrix m;
var m = default(ColorMatrix);

m.M11 = value1.M11 * value2;
m.M12 = value1.M12 * value2;
Expand Down
23 changes: 13 additions & 10 deletions tests/ImageSharp.Benchmarks/Codecs/DecodeTga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public class DecodeTga : BenchmarkBase
{
private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage);

private readonly PfimConfig pfimConfig = new PfimConfig(allocator: new PfimAllocator());

private byte[] data;

[Params(TestImages.Tga.Bit24)]
Expand Down Expand Up @@ -77,15 +79,16 @@ public void Return(byte[] data)
public int Rented => this.rented;
}

// RESULTS (07/01/2020)
//| Method | Runtime | TestImage | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
//|------------------ |-------------- |-------------------- |-------------:|-------------:|-----------:|------:|-------:|------:|------:|----------:|
//| 'ImageMagick Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 1,778.965 us | 1,711.088 us | 93.7905 us | 1.000 | 1.9531 | - | - | 13668 B |
//| 'ImageSharp Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 38.659 us | 6.886 us | 0.3774 us | 0.022 | 0.3052 | - | - | 1316 B |
//| 'Pfim Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 6.752 us | 10.268 us | 0.5628 us | 0.004 | 0.0687 | - | - | 313 B |
//| | | | | | | | | | | |
//| 'ImageMagick Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 1,407.585 us | 124.215 us | 6.8087 us | 1.000 | 1.9531 | - | - | 13307 B |
//| 'ImageSharp Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 17.958 us | 9.352 us | 0.5126 us | 0.013 | 0.2747 | - | - | 1256 B |
//| 'Pfim Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 5.645 us | 2.279 us | 0.1249 us | 0.004 | 0.0610 | - | - | 280 B |
/* RESULTS (07/01/2020)
| Method | Runtime | TestImage | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------ |-------------- |-------------------- |-------------:|-------------:|-----------:|------:|-------:|------:|------:|----------:|
| 'ImageMagick Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 1,778.965 us | 1,711.088 us | 93.7905 us | 1.000 | 1.9531 | - | - | 13668 B |
| 'ImageSharp Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 38.659 us | 6.886 us | 0.3774 us | 0.022 | 0.3052 | - | - | 1316 B |
| 'Pfim Tga' | .NET 4.7.2 | Tga/targa_24bit.tga | 6.752 us | 10.268 us | 0.5628 us | 0.004 | 0.0687 | - | - | 313 B |
| | | | | | | | | | | |
| 'ImageMagick Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 1,407.585 us | 124.215 us | 6.8087 us | 1.000 | 1.9531 | - | - | 13307 B |
| 'ImageSharp Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 17.958 us | 9.352 us | 0.5126 us | 0.013 | 0.2747 | - | - | 1256 B |
| 'Pfim Tga' | .NET Core 2.1 | Tga/targa_24bit.tga | 5.645 us | 2.279 us | 0.1249 us | 0.004 | 0.0610 | - | - | 280 B |
*/
}
}
16 changes: 12 additions & 4 deletions tests/ImageSharp.Benchmarks/Codecs/EncodeBmpMultiple.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
Expand All @@ -16,13 +16,21 @@ public class EncodeBmpMultiple : MultiImageBenchmarkBase.WithImagesPreloaded
[Benchmark(Description = "EncodeBmpMultiple - ImageSharp")]
public void EncodeBmpImageSharp()
{
this.ForEachImageSharpImage((img, ms) => { img.Save(ms, new BmpEncoder()); return null; });
this.ForEachImageSharpImage((img, ms) =>
{
img.Save(ms, new BmpEncoder());
return null;
});
}

[Benchmark(Baseline = true, Description = "EncodeBmpMultiple - System.Drawing")]
public void EncodeBmpSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Bmp); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Bmp);
return null;
});
}
}
}
}
13 changes: 9 additions & 4 deletions tests/ImageSharp.Benchmarks/Codecs/EncodeGifMultiple.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
Expand All @@ -24,14 +24,19 @@ public void EncodeGifImageSharp()
{
// Try to get as close to System.Drawing's output as possible
var options = new GifEncoder { Quantizer = new WebSafePaletteQuantizer(false) };
img.Save(ms, options); return null;
img.Save(ms, options);
return null;
});
}

[Benchmark(Baseline = true, Description = "EncodeGifMultiple - System.Drawing")]
public void EncodeGifSystemDrawing()
{
this.ForEachSystemDrawingImage((img, ms) => { img.Save(ms, ImageFormat.Gif); return null; });
this.ForEachSystemDrawingImage((img, ms) =>
{
img.Save(ms, ImageFormat.Gif);
return null;
});
}
}
}
}
2 changes: 1 addition & 1 deletion tests/ImageSharp.Benchmarks/Codecs/EncodeTga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ReadImages()
{
if (this.tgaCore == null)
{
this.tgaCore = Image.Load<Rgba32>(TestImageFullPath);
this.tgaCore = Image.Load<Rgba32>(this.TestImageFullPath);
this.tgaMagick = new MagickImage(this.TestImageFullPath);
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/ImageSharp.Benchmarks/Codecs/ImageBenchmarkTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

// This file contains small, cheap and "unit test" benchmarks to test MultiImageBenchmarkBase.
// Need this because there are no real test cases for the common benchmark utility stuff.

// Uncomment this to enable benchmark testing
// #define TEST

#if TEST

// ReSharper disable InconsistentNaming
Expand Down Expand Up @@ -76,4 +75,4 @@ public void Run()
}
}

#endif
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand All @@ -9,8 +9,8 @@

using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Memory;
// ReSharper disable InconsistentNaming

// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations
{
public class Block8x8F_CopyTo1x1
Expand Down Expand Up @@ -130,4 +130,4 @@ public void UseVector8_V2()
// Conclusion:
// Doesn't worth to bother with this
}
}
}
Loading