diff --git a/ImageSharp.sln b/ImageSharp.sln
index 628fa7015..6e389421e 100644
--- a/ImageSharp.sln
+++ b/ImageSharp.sln
@@ -22,6 +22,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{815C0625-CD3D-440F-9F80-2D83856AB7AE}"
+ ProjectSection(SolutionItems) = preProject
+ src\README.md = src\README.md
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{56801022-D71A-4FBE-BC5B-CBA08E2284EC}"
EndProject
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
index 8414807e0..da5d24637 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
@@ -26,7 +26,7 @@ namespace ImageSharp.Formats
public class BmpDecoder : IImageDecoder
{
///
- public Image Decode(Stream stream, IDecoderOptions options, Configuration configuration)
+ public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel
{
diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs
index 2e56b0bab..2eb89de8f 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs
@@ -14,24 +14,24 @@ namespace ImageSharp.Formats
public class GifDecoder : IImageDecoder
{
///
- public Image Decode(Stream stream, IDecoderOptions options, Configuration configuration)
+ public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel
{
IGifDecoderOptions gifOptions = GifDecoderOptions.Create(options);
- return this.Decode(stream, gifOptions, configuration);
+ return this.Decode(configuration, stream, gifOptions);
}
///
/// Decodes the image from the specified stream to the .
///
/// The pixel format.
+ /// The configuration.
/// The containing image data.
/// The options for the decoder.
- /// The configuration.
/// The image thats been decoded.
- public Image Decode(Stream stream, IGifDecoderOptions options, Configuration configuration)
+ public Image Decode(Configuration configuration, Stream stream, IGifDecoderOptions options)
where TColor : struct, IPixel
{
return new GifDecoderCore(options, configuration).Decode(stream);
diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs
index 8da23d499..c85fbef10 100644
--- a/src/ImageSharp/Formats/IImageDecoder.cs
+++ b/src/ImageSharp/Formats/IImageDecoder.cs
@@ -17,11 +17,11 @@ namespace ImageSharp.Formats
/// Decodes the image from the specified stream to the .
///
/// The pixel format.
+ /// The configuration for the image.
/// The containing image data.
/// The options for the decoder.
- /// The configuration for the image.
/// The decoded image
- Image Decode(Stream stream, IDecoderOptions options, Configuration configuration)
+ Image Decode(Configuration configuration, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel;
}
}
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
index 254506af0..0aac31603 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
@@ -14,7 +14,7 @@ namespace ImageSharp.Formats
public class JpegDecoder : IImageDecoder
{
///
- public Image Decode(Stream stream, IDecoderOptions options, Configuration configuration)
+ public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel
{
Guard.NotNull(stream, "stream");
diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs
index bf17ad142..d0a820c17 100644
--- a/src/ImageSharp/Formats/Png/PngDecoder.cs
+++ b/src/ImageSharp/Formats/Png/PngDecoder.cs
@@ -31,24 +31,24 @@ namespace ImageSharp.Formats
public class PngDecoder : IImageDecoder
{
///
- public Image Decode(Stream stream, IDecoderOptions options, Configuration configuration)
+ public Image Decode(Configuration configuration, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel
{
IPngDecoderOptions pngOptions = PngDecoderOptions.Create(options);
- return this.Decode(stream, pngOptions, configuration);
+ return this.Decode(configuration, stream, pngOptions);
}
///
/// Decodes the image from the specified stream to the .
///
/// The pixel format.
+ /// The configuration for the image.
/// The containing image data.
/// The options for the decoder.
- /// The configuration for the image.
/// The decoded image.
- public Image Decode(Stream stream, IPngDecoderOptions options, Configuration configuration)
+ public Image Decode(Configuration configuration, Stream stream, IPngDecoderOptions options)
where TColor : struct, IPixel
{
return new PngDecoderCore(options, configuration).Decode(stream);
diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs
index a86a6e948..c1c137122 100644
--- a/src/ImageSharp/Image.Decode.cs
+++ b/src/ImageSharp/Image.Decode.cs
@@ -67,7 +67,7 @@ namespace ImageSharp
return null;
}
- Image img = format.Decoder.Decode(stream, options, config);
+ Image img = format.Decoder.Decode(config, stream, options);
img.CurrentImageFormat = format;
return img;
}
diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs
index be807aef4..41ac7757e 100644
--- a/src/ImageSharp/Image.FromStream.cs
+++ b/src/ImageSharp/Image.FromStream.cs
@@ -182,7 +182,7 @@ namespace ImageSharp
public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
where TColor : struct, IPixel
{
- return WithSeekableStream(stream, s => decoder.Decode(s, options, Configuration.Default));
+ return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options));
}
///
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 000000000..3764e03cb
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,7 @@
+# ImageSharp core libraries
+
+## Coding conventions
+
+### Argument ordering
+
+- When passing a `Configuration` object it should be the first argument
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs
index 91b907e19..a7f57ca1c 100644
--- a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs
+++ b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs
@@ -44,7 +44,7 @@ namespace ImageSharp.Tests
this.localFormat.Setup(x => x.IsSupportedFileFormat(It.IsAny())).Returns(true);
this.localFormat.Setup(x => x.SupportedExtensions).Returns(new string[] { "png", "jpg" });
- this.localDecoder.Setup(x => x.Decode(It.IsAny(), It.IsAny(), It.IsAny()))
+ this.localDecoder.Setup(x => x.Decode(It.IsAny(), It.IsAny(), It.IsAny()))
.Callback((s, o, c) => {
using (var ms = new MemoryStream())
@@ -133,7 +133,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(stream, null, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, stream, null));
}
@@ -147,7 +147,7 @@ namespace ImageSharp.Tests
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(stream, null, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, stream, null));
}
@@ -160,7 +160,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(stream, this.decoderOptions, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, stream, this.decoderOptions));
}
@@ -174,7 +174,7 @@ namespace ImageSharp.Tests
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(stream, this.decoderOptions, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, stream, this.decoderOptions));
}
@@ -187,7 +187,7 @@ namespace ImageSharp.Tests
Image img = Image.Load(stream, this.localDecoder.Object);
Assert.NotNull(img);
- this.localDecoder.Verify(x => x.Decode(stream, null, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, stream, null));
}
[Fact]
@@ -198,7 +198,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
- this.localDecoder.Verify(x => x.Decode(stream, null, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, stream, null));
}
[Fact]
@@ -208,7 +208,7 @@ namespace ImageSharp.Tests
Image img = Image.Load(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
- this.localDecoder.Verify(x => x.Decode(stream, this.decoderOptions, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, stream, this.decoderOptions));
}
[Fact]
@@ -219,7 +219,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
- this.localDecoder.Verify(x => x.Decode(stream, this.decoderOptions, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, stream, this.decoderOptions));
}
[Fact]
@@ -281,7 +281,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), null, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, It.IsAny(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -296,7 +296,7 @@ namespace ImageSharp.Tests
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), null, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, It.IsAny(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -309,7 +309,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), this.decoderOptions, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, It.IsAny(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -323,7 +323,7 @@ namespace ImageSharp.Tests
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), this.decoderOptions, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, It.IsAny(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -335,7 +335,7 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), null, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, It.IsAny(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -346,7 +346,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), null, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, It.IsAny(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -356,7 +356,7 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), this.decoderOptions, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, It.IsAny(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -367,7 +367,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
- this.localDecoder.Verify(x => x.Decode(It.IsAny(), this.decoderOptions, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, It.IsAny(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@@ -430,7 +430,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, null, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, this.DataStream, null));
}
@@ -443,7 +443,7 @@ namespace ImageSharp.Tests
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, null, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, this.DataStream, null));
}
@@ -455,7 +455,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, this.decoderOptions, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, this.DataStream, this.decoderOptions));
}
@@ -468,7 +468,7 @@ namespace ImageSharp.Tests
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, this.decoderOptions, this.LocalConfiguration));
+ this.localDecoder.Verify(x => x.Decode(this.LocalConfiguration, this.DataStream, this.decoderOptions));
}
@@ -479,7 +479,7 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, null, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, this.DataStream, null));
}
[Fact]
@@ -489,7 +489,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, null, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, this.DataStream, null));
}
[Fact]
@@ -498,7 +498,7 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, this.decoderOptions, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, this.DataStream, this.decoderOptions));
}
[Fact]
@@ -508,7 +508,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
- this.localDecoder.Verify(x => x.Decode(this.DataStream, this.decoderOptions, Configuration.Default));
+ this.localDecoder.Verify(x => x.Decode(Configuration.Default, this.DataStream, this.decoderOptions));
}
public void Dispose()
diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs
index 5894151dc..084ad5993 100644
--- a/tests/ImageSharp.Tests/TestFormat.cs
+++ b/tests/ImageSharp.Tests/TestFormat.cs
@@ -149,7 +149,7 @@ namespace ImageSharp.Tests
}
- public Image Decode(Stream stream, IDecoderOptions options, Configuration config) where TColor : struct, IPixel
+ public Image Decode(Configuration config, Stream stream, IDecoderOptions options) where TColor : struct, IPixel
{
var ms = new MemoryStream();