Changed all occurenceas of var#1
Conversation
* Also added Rider settings. Some Rules are not supported by Rider.
There was a problem hiding this comment.
30 file(s) reviewed, 30 comment(s)
Edit PR Review Bot Settings | Greptile
| csharp_style_var_for_built_in_types = false:error | ||
| csharp_style_var_when_type_is_apparent = false:error | ||
| csharp_style_var_elsewhere = false:error |
There was a problem hiding this comment.
style: Changing var preferences from warning to error may be too restrictive. Consider keeping as warning to maintain flexibility where explicit types harm readability.
| dotnet_style_object_initializer = true:error | ||
| dotnet_style_collection_initializer = true:error |
There was a problem hiding this comment.
style: Making object/collection initializer rules errors instead of warnings could be overly strict for cases where alternative syntax improves clarity.
| csharp_style_prefer_index_operator = true:warning | ||
| csharp_style_prefer_range_operator = true:warning | ||
| csharp_style_implicit_object_creation_when_type_is_apparent = true:warning | ||
| csharp_style_implicit_object_creation_when_type_is_apparent = true:error |
There was a problem hiding this comment.
style: Consider keeping implicit object creation as warning - error severity may force unnecessary verbosity in obvious type scenarios.
| <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestVarOrType_005FBuiltInTypes/@EntryIndexedValue">ERROR</s:String> | ||
| <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestVarOrType_005FElsewhere/@EntryIndexedValue">ERROR</s:String> | ||
| <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestVarOrType_005FSimpleTypes/@EntryIndexedValue">ERROR</s:String> |
There was a problem hiding this comment.
style: Setting var-to-type suggestions as errors may be too strict and could reduce code readability in cases where types are obvious or very long. Consider using WARNING instead of ERROR to provide flexibility.
| public partial struct Color | ||
| { | ||
| private static readonly Lazy<Color[]> WebSafePaletteLazy = new Lazy<Color[]>(CreateWebSafePalette, true); | ||
| private static readonly Lazy<Color[]> WebSafePaletteLazy = new(CreateWebSafePalette, true); |
There was a problem hiding this comment.
style: Consider keeping explicit type for Lazy<Color[]> constructor since removing it doesn't improve readability here
|
|
||
| nuint count = (uint)redChannel.Length / 4; | ||
| destination.Fill(new Rgba32(0, 0, 0, 255)); | ||
| destination.Fill(new(0, 0, 0, 255)); |
There was a problem hiding this comment.
logic: This change removes the explicit type name Rgba32 from the constructor, which seems to contradict the PR's goal of making types more explicit. Consider keeping new Rgba32(0, 0, 0, 255) for clarity.
| internal static Vector4 PseudoRound(this Vector4 v) | ||
| { | ||
| Vector4 sign = Numerics.Clamp(v, new Vector4(-1), new Vector4(1)); | ||
| Vector4 sign = Numerics.Clamp(v, new(-1), new(1)); |
There was a problem hiding this comment.
style: The simplified constructor syntax 'new(-1)' relies on type inference from the Clamp method signature. Consider keeping the explicit 'new Vector4(-1)' for better readability and maintainability.
| /// Does not necessarily fit all use cases! | ||
| /// </summary> | ||
| public static readonly TolerantMath Default = new TolerantMath(1e-8); | ||
| public static readonly TolerantMath Default = new(1e-8); |
There was a problem hiding this comment.
style: The target-typed new expression is valid here since C# 9.0, but consider keeping the explicit type for better readability in static field initialization
| if (unit == PixelResolutionUnit.AspectRatio) | ||
| { | ||
| return new ExifResolutionValues(exifUnit, null, null); | ||
| return new(exifUnit, null, null); |
There was a problem hiding this comment.
style: Consider keeping the explicit type ExifResolutionValues here for better readability since the type is not immediately obvious from the constructor parameters
| } | ||
|
|
||
| return new ExifResolutionValues(exifUnit, horizontal, vertical); | ||
| return new(exifUnit, horizontal, vertical); |
There was a problem hiding this comment.
style: Consider keeping the explicit type ExifResolutionValues here for better readability since the type is not immediately obvious from the constructor parameters
To have a consistent code base I changed all usages of var and changed the editorconfig rule to error.
Do you want this things to be on error in the editorconfig?
Greptile Summary
This PR enforces explicit type declarations across the ImageSharp codebase by modifying code style rules and updating syntax.
.editorconfigand added.DotSettingsto enforce explicit type declarations as errors instead of warningsvarusage with explicit types throughout the codebase for consistencynew()expressions (C# 9.0 feature)