Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit eb82ffd

Browse files
Update submodule and fix warnings.
1 parent eff1760 commit eb82ffd

11 files changed

Lines changed: 528 additions & 59 deletions

.editorconfig

Lines changed: 372 additions & 0 deletions
Large diffs are not rendered by default.

.gitattributes

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
###############################################################################
2+
# Set default behavior to:
3+
# treat as text and
4+
# normalize to Unix-style line endings
5+
###############################################################################
6+
* text eol=lf
7+
8+
###############################################################################
9+
# Set explicit file behavior to:
10+
# treat as text and
11+
# normalize to Unix-style line endings
12+
###############################################################################
13+
*.asm text eol=lf
14+
*.c text eol=lf
15+
*.clj text eol=lf
16+
*.cmd text eol=lf
17+
*.cpp text eol=lf
18+
*.css text eol=lf
19+
*.cxx text eol=lf
20+
*.config text eol=lf
21+
*.DotSettings text eol=lf
22+
*.erl text eol=lf
23+
*.fs text eol=lf
24+
*.fsx text eol=lf
25+
*.h text eol=lf
26+
*.htm text eol=lf
27+
*.html text eol=lf
28+
*.hs text eol=lf
29+
*.hxx text eol=lf
30+
*.java text eol=lf
31+
*.js text eol=lf
32+
*.json text eol=lf
33+
*.less text eol=lf
34+
*.lisp text eol=lf
35+
*.lua text eol=lf
36+
*.m text eol=lf
37+
*.md text eol=lf
38+
*.php text eol=lf
39+
*.props text eol=lf
40+
*.ps1 text eol=lf
41+
*.py text eol=lf
42+
*.rb text eol=lf
43+
*.resx text eol=lf
44+
*.runsettings text eol=lf
45+
*.ruleset text eol=lf
46+
*.sass text eol=lf
47+
*.scss text eol=lf
48+
*.sh text eol=lf
49+
*.sql text eol=lf
50+
*.svg text eol=lf
51+
*.targets text eol=lf
52+
*.tt text eol=crlf
53+
*.ttinclude text eol=crlf
54+
*.txt text eol=lf
55+
*.vb text eol=lf
56+
*.yml text eol=lf
57+
58+
###############################################################################
59+
# Set explicit file behavior to:
60+
# treat as text
61+
# normalize to Unix-style line endings and
62+
# diff as csharp
63+
###############################################################################
64+
*.cs text eol=lf diff=csharp
65+
66+
###############################################################################
67+
# Set explicit file behavior to:
68+
# treat as text
69+
# normalize to Unix-style line endings and
70+
# use a union merge when resoling conflicts
71+
###############################################################################
72+
*.csproj text eol=lf merge=union
73+
*.dbproj text eol=lf merge=union
74+
*.fsproj text eol=lf merge=union
75+
*.ncrunchproject text eol=lf merge=union
76+
*.vbproj text eol=lf merge=union
77+
78+
###############################################################################
79+
# Set explicit file behavior to:
80+
# treat as text
81+
# normalize to Windows-style line endings and
82+
# use a union merge when resoling conflicts
83+
###############################################################################
84+
*.sln text eol=crlf merge=union
85+
86+
###############################################################################
87+
# Set explicit file behavior to:
88+
# treat as binary
89+
###############################################################################
90+
*.bmp binary
91+
*.dll binary
92+
*.exe binary
93+
*.gif binary
94+
*.jpg binary
95+
*.png binary
96+
*.ttf binary
97+
*.snk binary
98+
99+
###############################################################################
100+
# Set explicit file behavior to:
101+
# diff as plain text
102+
###############################################################################
103+
*.doc diff=astextplain
104+
*.docx diff=astextplain
105+
*.dot diff=astextplain
106+
*.pdf diff=astextplain
107+
*.pptx diff=astextplain
108+
*.rtf diff=astextplain

src/SixLabors.Core/SixLabors.Core.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</PropertyGroup>
2424

2525
<PropertyGroup>
26-
<CodeAnalysisRuleSet>..\SixLabors.ruleset</CodeAnalysisRuleSet>
26+
<CodeAnalysisRuleSet>..\..\shared-infrastructure\SixLabors.ruleset</CodeAnalysisRuleSet>
2727
</PropertyGroup>
2828

2929
<!-- TODO: Include .NETSTANDARD2.1 when released-->
@@ -39,9 +39,6 @@
3939
<Compile Include="..\..\shared-infrastructure\**\*.cs" />
4040
<AdditionalFiles Include="..\..\shared-infrastructure\stylecop.json" />
4141
</ItemGroup>
42-
<PropertyGroup>
43-
<CodeAnalysisRuleSet>..\..\shared-infrastructure\SixLabors.ruleset</CodeAnalysisRuleSet>
44-
</PropertyGroup>
4542

4643
<ItemGroup>
4744
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">

src/SixLabors.ruleset

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/SixLabors.Core.Tests/Helpers/DebugGuardTests.cs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
// tell this file to enable debug conditional method calls, i.e. all the debug guard calls
55
#define DEBUG
66

77
using System;
8+
using System.Collections.Generic;
89
using System.Diagnostics;
910
using System.Linq;
1011
using System.Reflection;
@@ -21,12 +22,12 @@ private class Foo
2122
[Fact]
2223
public void AllStaticMethodsOnOnDebugGuardHaveDEBUGConditional()
2324
{
24-
var methods = typeof(DebugGuard).GetTypeInfo().GetMethods()
25+
IEnumerable<MethodInfo> methods = typeof(DebugGuard).GetTypeInfo().GetMethods()
2526
.Where(x => x.IsStatic);
2627

27-
foreach (var m in methods)
28+
foreach (MethodInfo m in methods)
2829
{
29-
var attribs = m.GetCustomAttributes<ConditionalAttribute>();
30+
IEnumerable<ConditionalAttribute> attribs = m.GetCustomAttributes<ConditionalAttribute>();
3031
Assert.True(attribs.Select(x => x.ConditionString).Contains("DEBUG"), $"Method '{m.Name}' does not have [Conditional(\"DEBUG\")] set.");
3132
}
3233
}
@@ -41,7 +42,7 @@ public void NotNull_WhenNull_Throws()
4142
[Fact]
4243
public void NotNull_WhenNotNull()
4344
{
44-
Foo foo = new Foo();
45+
var foo = new Foo();
4546
Guard.NotNull(foo, nameof(foo));
4647
}
4748

@@ -152,10 +153,8 @@ public void MustBeLessThan_IsLess_ThrowsNoException()
152153
[InlineData(1, 1)]
153154
public void MustBeLessThan_IsGreaterOrEqual_ThrowsNoException(int value, int max)
154155
{
155-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
156-
{
157-
DebugGuard.MustBeLessThan(value, max, "myParamName");
158-
});
156+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(
157+
() => DebugGuard.MustBeLessThan(value, max, "myParamName"));
159158

160159
Assert.Equal("myParamName", exception.ParamName);
161160
Assert.Contains($"Value {value} must be less than {max}.", exception.Message);
@@ -172,10 +171,7 @@ public void MustBeLessThanOrEqualTo_IsLessOrEqual_ThrowsNoException(int value, i
172171
[Fact]
173172
public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException()
174173
{
175-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
176-
{
177-
DebugGuard.MustBeLessThanOrEqualTo(2, 1, "myParamName");
178-
});
174+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => DebugGuard.MustBeLessThanOrEqualTo(2, 1, "myParamName"));
179175

180176
Assert.Equal("myParamName", exception.ParamName);
181177
Assert.Contains($"Value 2 must be less than or equal to 1.", exception.Message);
@@ -192,10 +188,8 @@ public void MustBeGreaterThan_IsGreater_ThrowsNoException()
192188
[InlineData(1, 1)]
193189
public void MustBeGreaterThan_IsLessOrEqual_ThrowsNoException(int value, int min)
194190
{
195-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
196-
{
197-
DebugGuard.MustBeGreaterThan(value, min, "myParamName");
198-
});
191+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(
192+
() => DebugGuard.MustBeGreaterThan(value, min, "myParamName"));
199193

200194
Assert.Equal("myParamName", exception.ParamName);
201195
Assert.Contains($"Value {value} must be greater than {min}.", exception.Message);
@@ -212,10 +206,8 @@ public void MustBeGreaterThanOrEqualTo_IsGreaterOrEqual_ThrowsNoException(int va
212206
[Fact]
213207
public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException()
214208
{
215-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
216-
{
217-
DebugGuard.MustBeGreaterThanOrEqualTo(1, 2, "myParamName");
218-
});
209+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(
210+
() => DebugGuard.MustBeGreaterThanOrEqualTo(1, 2, "myParamName"));
219211

220212
Assert.Equal("myParamName", exception.ParamName);
221213
Assert.Contains($"Value 1 must be greater than or equal to 2.", exception.Message);
@@ -232,10 +224,8 @@ public void MustBeSizedAtLeast_Array_LengthIsGreaterOrEqual_ThrowsNoException(in
232224
[Fact]
233225
public void MustBeSizedAtLeast_Array_LengthIsLess_ThrowsException()
234226
{
235-
var exception = Assert.Throws<ArgumentException>(() =>
236-
{
237-
DebugGuard.MustBeSizedAtLeast<int>(new int[] { 1, 2 }, 3, "myParamName");
238-
});
227+
ArgumentException exception = Assert.Throws<ArgumentException>(
228+
() => DebugGuard.MustBeSizedAtLeast<int>(new int[] { 1, 2 }, 3, "myParamName"));
239229

240230
Assert.Equal("myParamName", exception.ParamName);
241231
Assert.Contains($"The size must be at least 3.", exception.Message);

tests/SixLabors.Core.Tests/Helpers/GuardTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void MustBeLessThan_IsLess_ThrowsNoException()
133133
[InlineData(1, 1)]
134134
public void MustBeLessThan_IsGreaterOrEqual_ThrowsNoException(int value, int max)
135135
{
136-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
136+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
137137
{
138138
Guard.MustBeLessThan(value, max, "myParamName");
139139
});
@@ -153,7 +153,7 @@ public void MustBeLessThanOrEqualTo_IsLessOrEqual_ThrowsNoException(int value, i
153153
[Fact]
154154
public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException()
155155
{
156-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
156+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
157157
{
158158
Guard.MustBeLessThanOrEqualTo(2, 1, "myParamName");
159159
});
@@ -173,7 +173,7 @@ public void MustBeGreaterThan_IsGreater_ThrowsNoException()
173173
[InlineData(1, 1)]
174174
public void MustBeGreaterThan_IsLessOrEqual_ThrowsNoException(int value, int min)
175175
{
176-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
176+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
177177
{
178178
Guard.MustBeGreaterThan(value, min, "myParamName");
179179
});
@@ -193,7 +193,7 @@ public void MustBeGreaterThanOrEqualTo_IsGreaterOrEqual_ThrowsNoException(int va
193193
[Fact]
194194
public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException()
195195
{
196-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
196+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
197197
{
198198
Guard.MustBeGreaterThanOrEqualTo(1, 2, "myParamName");
199199
});
@@ -216,7 +216,7 @@ public void MustBeBetweenOrEqualTo_IsBetweenOrEqual_ThrowsNoException(int value,
216216
[InlineData(4, 1, 3)]
217217
public void MustBeBetweenOrEqualTo_IsLessOrGreater_ThrowsNoException(int value, int min, int max)
218218
{
219-
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
219+
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
220220
{
221221
Guard.MustBeBetweenOrEqualTo(value, min, max, "myParamName");
222222
});
@@ -236,7 +236,7 @@ public void MustBeSizedAtLeast_Array_LengthIsGreaterOrEqual_ThrowsNoException(in
236236
[Fact]
237237
public void MustBeSizedAtLeast_Array_LengthIsLess_ThrowsException()
238238
{
239-
var exception = Assert.Throws<ArgumentException>(() =>
239+
ArgumentException exception = Assert.Throws<ArgumentException>(() =>
240240
{
241241
Guard.MustBeSizedAtLeast<int>(new int[] { 1, 2 }, 3, "myParamName");
242242
});

tests/SixLabors.Core.Tests/Memory/ArrayPoolMemoryAllocatorTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void WhenPassedOnly_MaxPooledBufferSizeInBytes_SmallerThresholdValueIsAut
6666
[Fact]
6767
public void When_PoolSelectorThresholdInBytes_IsGreaterThan_MaxPooledBufferSizeInBytes_ExceptionIsThrown()
6868
{
69-
Assert.ThrowsAny<Exception>(() => { new ArrayPoolMemoryAllocator(100, 200); });
69+
Assert.ThrowsAny<Exception>(() => new ArrayPoolMemoryAllocator(100, 200));
7070
}
7171
}
7272

@@ -169,13 +169,13 @@ public void AllocationOverLargeArrayThreshold_UsesDifferentPool()
169169
return;
170170
}
171171

172-
int arrayLengthThreshold = PoolSelectorThresholdInBytes / sizeof(int);
172+
const int ArrayLengthThreshold = PoolSelectorThresholdInBytes / sizeof(int);
173173

174-
IMemoryOwner<int> small = this.MemoryAllocator.Allocate<int>(arrayLengthThreshold - 1);
174+
IMemoryOwner<int> small = this.MemoryAllocator.Allocate<int>(ArrayLengthThreshold - 1);
175175
ref int ptr2Small = ref small.GetReference();
176176
small.Dispose();
177177

178-
IMemoryOwner<int> large = this.MemoryAllocator.Allocate<int>(arrayLengthThreshold + 1);
178+
IMemoryOwner<int> large = this.MemoryAllocator.Allocate<int>(ArrayLengthThreshold + 1);
179179

180180
Assert.False(Unsafe.AreSame(ref ptr2Small, ref large.GetReference()));
181181
}
@@ -227,7 +227,7 @@ public void CreateWithModeratePooling()
227227
[StructLayout(LayoutKind.Sequential)]
228228
private struct Rgba32
229229
{
230-
private uint dummy;
230+
private readonly uint dummy;
231231
}
232232

233233
private const int SizeOfLargeStruct = MaxPooledBufferSizeInBytes / 5;
@@ -242,16 +242,16 @@ private struct LargeStruct
242242
[InlineData((int.MaxValue / SizeOfLargeStruct) + 1)]
243243
public void AllocateIncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
244244
{
245-
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.Allocate<LargeStruct>(length));
245+
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.Allocate<LargeStruct>(length));
246246
Assert.Equal("length", ex.ParamName);
247247
}
248248

249249
[Theory]
250250
[InlineData(-1)]
251251
public void AllocateManagedByteBuffer_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
252252
{
253-
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));
253+
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));
254254
Assert.Equal("length", ex.ParamName);
255255
}
256256
}
257-
}
257+
}

tests/SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public BufferTests()
2323
[InlineData(-1)]
2424
public void Allocate_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
2525
{
26-
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.Allocate<BigStruct>(length));
26+
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.Allocate<BigStruct>(length));
2727
Assert.Equal("length", ex.ParamName);
2828
}
2929

3030
[Theory]
3131
[InlineData(-1)]
3232
public void AllocateManagedByteBuffer_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
3333
{
34-
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));
34+
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));
3535
Assert.Equal("length", ex.ParamName);
3636
}
3737

0 commit comments

Comments
 (0)