Skip to content

Commit e7d25a2

Browse files
Merge pull request #2189 from SixLabors/js/remove-obsolete-code
Remove obsolete code
2 parents 8d7d413 + e9049e2 commit e7d25a2

File tree

360 files changed

+3651
-5129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+3651
-5129
lines changed

.editorconfig

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Version: 2.1.0 (Using https://semver.org/)
2-
# Updated: 2021-03-03
1+
# Version: 4.1.1 (Using https://semver.org/)
2+
# Updated: 2022-05-23
33
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
44
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
55
# See http://EditorConfig.org for more information about .editorconfig files.
@@ -49,11 +49,11 @@ indent_size = 2
4949
indent_size = 2
5050

5151
# Markdown Files
52-
[*.md]
52+
[*.{md,mdx}]
5353
trim_trailing_whitespace = false
5454

5555
# Web Files
56-
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}]
56+
[*.{htm,html,js,jsm,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}]
5757
indent_size = 2
5858

5959
# Batch Files
@@ -75,7 +75,7 @@ indent_style = tab
7575

7676
[*.{cs,csx,cake,vb,vbx}]
7777
# Default Severity for all .NET Code Style rules below
78-
dotnet_analyzer_diagnostic.category-style.severity = warning
78+
dotnet_analyzer_diagnostic.severity = warning
7979

8080
##########################################
8181
# Language Rules
@@ -128,14 +128,15 @@ file_header_template = Copyright (c) Six Labors.\nLicensed under the Six Labors
128128
# dotnet_diagnostic.SA1636.severity = none
129129

130130
# Undocumented
131-
dotnet_style_operator_placement_when_wrapping = end_of_line
131+
dotnet_style_operator_placement_when_wrapping = end_of_line:warning
132+
csharp_style_prefer_null_check_over_type_check = true:warning
132133

133134
# C# Style Rules
134135
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
135136
[*.{cs,csx,cake}]
136137
# 'var' preferences
137-
csharp_style_var_for_built_in_types = never
138-
csharp_style_var_when_type_is_apparent = true:warning
138+
csharp_style_var_for_built_in_types = false:warning
139+
csharp_style_var_when_type_is_apparent = false:warning
139140
csharp_style_var_elsewhere = false:warning
140141
# Expression-bodied members
141142
csharp_style_expression_bodied_methods = true:warning
@@ -200,12 +201,15 @@ dotnet_diagnostic.IDE0059.severity = suggestion
200201
# Organize using directives
201202
dotnet_sort_system_directives_first = true
202203
dotnet_separate_import_directive_groups = false
204+
# Dotnet namespace options
205+
dotnet_style_namespace_match_folder = true:suggestion
206+
dotnet_diagnostic.IDE0130.severity = suggestion
203207

204208
# C# formatting rules
205209
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
206210
[*.{cs,csx,cake}]
207211
# Newline options
208-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
212+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#new-line-options
209213
csharp_new_line_before_open_brace = all
210214
csharp_new_line_before_else = true
211215
csharp_new_line_before_catch = true
@@ -214,15 +218,15 @@ csharp_new_line_before_members_in_object_initializers = true
214218
csharp_new_line_before_members_in_anonymous_types = true
215219
csharp_new_line_between_query_expression_clauses = true
216220
# Indentation options
217-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options
221+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#indentation-options
218222
csharp_indent_case_contents = true
219223
csharp_indent_switch_labels = true
220224
csharp_indent_labels = no_change
221225
csharp_indent_block_contents = true
222226
csharp_indent_braces = false
223227
csharp_indent_case_contents_when_block = false
224228
# Spacing options
225-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options
229+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#spacing-options
226230
csharp_space_after_cast = false
227231
csharp_space_after_keywords_in_control_flow_statements = true
228232
csharp_space_between_parentheses = false
@@ -246,7 +250,7 @@ csharp_space_before_open_square_brackets = false
246250
csharp_space_between_empty_square_brackets = false
247251
csharp_space_between_square_brackets = false
248252
# Wrap options
249-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
253+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options
250254
csharp_preserve_single_line_statements = false
251255
csharp_preserve_single_line_blocks = true
252256

@@ -448,4 +452,4 @@ dotnet_naming_rule.parameters_rule.severity = warning
448452
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
449453
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
450454
# OTHER DEALINGS IN THE SOFTWARE.
451-
##########################################
455+
##########################################

src/Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2222
</PropertyGroup>
2323

24+
<PropertyGroup>
25+
<CodeAnalysisRuleSet>..\ImageSharp.ruleset</CodeAnalysisRuleSet>
26+
</PropertyGroup>
27+
2428
<ItemGroup>
2529
<!-- DynamicProxyGenAssembly2 is needed so Moq can use our internals -->
2630
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" Key="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />

src/ImageSharp.ruleset

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="ImageSharp" ToolsVersion="17.0">
3+
<Include Path="..\shared-infrastructure\sixlabors.ruleset" Action="Default" />
4+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
5+
<Rule Id="SA1011" Action="None" />
6+
</Rules>
7+
</RuleSet>

src/ImageSharp/Advanced/AdvancedImageExtensions.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Globalization;
67
using System.IO;
78
using System.Text;
89
using System.Threading;
@@ -34,11 +35,11 @@ public static IImageEncoder DetectEncoder(this Image source, string filePath)
3435
IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
3536
if (format is null)
3637
{
37-
var sb = new StringBuilder();
38-
sb.AppendLine($"No encoder was found for extension '{ext}'. Registered encoders include:");
38+
StringBuilder sb = new();
39+
sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}'. Registered encoders include:");
3940
foreach (IImageFormat fmt in source.GetConfiguration().ImageFormats)
4041
{
41-
sb.AppendFormat(" - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
42+
sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
4243
}
4344

4445
throw new NotSupportedException(sb.ToString());
@@ -48,11 +49,11 @@ public static IImageEncoder DetectEncoder(this Image source, string filePath)
4849

4950
if (encoder is null)
5051
{
51-
var sb = new StringBuilder();
52-
sb.AppendLine($"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
52+
StringBuilder sb = new();
53+
sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
5354
foreach (KeyValuePair<IImageFormat, IImageEncoder> enc in source.GetConfiguration().ImageFormatsManager.ImageEncoders)
5455
{
55-
sb.AppendFormat(" - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
56+
sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
5657
}
5758

5859
throw new NotSupportedException(sb.ToString());
@@ -116,6 +117,7 @@ private static Configuration GetConfiguration(IConfigurationProvider source)
116117
/// Certain Image Processors may invalidate the returned <see cref="IMemoryGroup{T}"/> and all it's buffers,
117118
/// therefore it's not recommended to mutate the image while holding a reference to it's <see cref="IMemoryGroup{T}"/>.
118119
/// </remarks>
120+
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="source"/> in <see langword="null"/>.</exception>
119121
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<TPixel> source)
120122
where TPixel : unmanaged, IPixel<TPixel>
121123
=> source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
@@ -131,13 +133,14 @@ public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this ImageFrame<T
131133
/// Certain Image Processors may invalidate the returned <see cref="IMemoryGroup{T}"/> and all it's buffers,
132134
/// therefore it's not recommended to mutate the image while holding a reference to it's <see cref="IMemoryGroup{T}"/>.
133135
/// </remarks>
136+
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="source"/> in <see langword="null"/>.</exception>
134137
public static IMemoryGroup<TPixel> GetPixelMemoryGroup<TPixel>(this Image<TPixel> source)
135138
where TPixel : unmanaged, IPixel<TPixel>
136139
=> source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
137140

138141
/// <summary>
139142
/// Gets the representation of the pixels as a <see cref="Span{T}"/> of contiguous memory
140-
/// at row <paramref name="rowIndex"/> beginning from the the first pixel on that row.
143+
/// at row <paramref name="rowIndex"/> beginning from the first pixel on that row.
141144
/// </summary>
142145
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
143146
/// <param name="source">The source.</param>
@@ -154,8 +157,8 @@ public static Memory<TPixel> DangerousGetPixelRowMemory<TPixel>(this ImageFrame<
154157
}
155158

156159
/// <summary>
157-
/// Gets the representation of the pixels as <see cref="Span{T}"/> of of contiguous memory
158-
/// at row <paramref name="rowIndex"/> beginning from the the first pixel on that row.
160+
/// Gets the representation of the pixels as <see cref="Span{T}"/> of contiguous memory
161+
/// at row <paramref name="rowIndex"/> beginning from the first pixel on that row.
159162
/// </summary>
160163
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
161164
/// <param name="source">The source.</param>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4+
using System;
5+
46
namespace SixLabors.ImageSharp.Advanced
57
{
68
/// <summary>
79
/// This is necessary to avoid being excluded from compilation in environments that do AOT builds, such as Unity's IL2CPP and Xamarin.
810
/// The only thing that matters is the class name.
911
/// There is no need to use or inherit from the PreserveAttribute class in each environment.
1012
/// </summary>
11-
internal sealed class PreserveAttribute : System.Attribute
13+
[AttributeUsage(AttributeTargets.Method)]
14+
internal sealed class PreserveAttribute : Attribute
1215
{
1316
}
1417
}

src/ImageSharp/Color/Color.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static Color FromPixel<TPixel>(TPixel pixel)
151151
[MethodImpl(InliningOptions.ShortMethod)]
152152
public static Color ParseHex(string hex)
153153
{
154-
var rgba = Rgba32.ParseHex(hex);
154+
Rgba32 rgba = Rgba32.ParseHex(hex);
155155

156156
return new Color(rgba);
157157
}
@@ -193,6 +193,7 @@ public static bool TryParseHex(string hex, out Color result)
193193
/// <returns>
194194
/// The <see cref="Color"/>.
195195
/// </returns>
196+
/// <exception cref="ArgumentException">Input string is not in the correct format.</exception>
196197
public static Color Parse(string input)
197198
{
198199
Guard.NotNull(input, nameof(input));
@@ -241,7 +242,7 @@ public static bool TryParse(string input, out Color result)
241242
/// <returns>The color having it's alpha channel altered.</returns>
242243
public Color WithAlpha(float alpha)
243244
{
244-
var v = (Vector4)this;
245+
Vector4 v = (Vector4)this;
245246
v.W = alpha;
246247
return new Color(v);
247248
}
@@ -290,12 +291,12 @@ public TPixel ToPixel<TPixel>()
290291
/// <param name="source">The source color span.</param>
291292
/// <param name="destination">The destination pixel span.</param>
292293
[MethodImpl(InliningOptions.ShortMethod)]
293-
public static void ToPixel<TPixel>(
294-
Configuration configuration,
295-
ReadOnlySpan<Color> source,
296-
Span<TPixel> destination)
294+
#pragma warning disable RCS1163 // Unused parameter.
295+
public static void ToPixel<TPixel>(Configuration configuration, ReadOnlySpan<Color> source, Span<TPixel> destination)
296+
#pragma warning restore RCS1163 // Unused parameter.
297297
where TPixel : unmanaged, IPixel<TPixel>
298298
{
299+
// TODO: Investigate bulk operations utilizing configuration parameter here.
299300
Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination));
300301
for (int i = 0; i < source.Length; i++)
301302
{

src/ImageSharp/ColorSpaces/CieLab.cs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

44
using System;
@@ -19,29 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces
1919
/// </summary>
2020
public static readonly CieXyz DefaultWhitePoint = Illuminants.D50;
2121

22-
/// <summary>
23-
/// Gets the lightness dimension.
24-
/// <remarks>A value usually ranging between 0 (black), 100 (diffuse white) or higher (specular white).</remarks>
25-
/// </summary>
26-
public readonly float L;
27-
28-
/// <summary>
29-
/// Gets the a color component.
30-
/// <remarks>A value usually ranging from -100 to 100. Negative is green, positive magenta.</remarks>
31-
/// </summary>
32-
public readonly float A;
33-
34-
/// <summary>
35-
/// Gets the b color component.
36-
/// <remarks>A value usually ranging from -100 to 100. Negative is blue, positive is yellow</remarks>
37-
/// </summary>
38-
public readonly float B;
39-
40-
/// <summary>
41-
/// Gets the reference white point of this color
42-
/// </summary>
43-
public readonly CieXyz WhitePoint;
44-
4522
/// <summary>
4623
/// Initializes a new instance of the <see cref="CieLab"/> struct.
4724
/// </summary>
@@ -95,6 +72,29 @@ public CieLab(Vector3 vector, CieXyz whitePoint)
9572
this.WhitePoint = whitePoint;
9673
}
9774

75+
/// <summary>
76+
/// Gets the lightness dimension.
77+
/// <remarks>A value usually ranging between 0 (black), 100 (diffuse white) or higher (specular white).</remarks>
78+
/// </summary>
79+
public readonly float L { get; }
80+
81+
/// <summary>
82+
/// Gets the a color component.
83+
/// <remarks>A value usually ranging from -100 to 100. Negative is green, positive magenta.</remarks>
84+
/// </summary>
85+
public readonly float A { get; }
86+
87+
/// <summary>
88+
/// Gets the b color component.
89+
/// <remarks>A value usually ranging from -100 to 100. Negative is blue, positive is yellow</remarks>
90+
/// </summary>
91+
public readonly float B { get; }
92+
93+
/// <summary>
94+
/// Gets the reference white point of this color
95+
/// </summary>
96+
public readonly CieXyz WhitePoint { get; }
97+
9898
/// <summary>
9999
/// Compares two <see cref="CieLab"/> objects for equality.
100100
/// </summary>
@@ -128,12 +128,10 @@ public CieLab(Vector3 vector, CieXyz whitePoint)
128128

129129
/// <inheritdoc/>
130130
[MethodImpl(InliningOptions.ShortMethod)]
131-
public bool Equals(CieLab other)
132-
{
133-
return this.L.Equals(other.L)
134-
&& this.A.Equals(other.A)
135-
&& this.B.Equals(other.B)
136-
&& this.WhitePoint.Equals(other.WhitePoint);
137-
}
131+
public bool Equals(CieLab other) =>
132+
this.L.Equals(other.L)
133+
&& this.A.Equals(other.A)
134+
&& this.B.Equals(other.B)
135+
&& this.WhitePoint.Equals(other.WhitePoint);
138136
}
139137
}

0 commit comments

Comments
 (0)