Skip to content

Commit e5ef201

Browse files
author
Ahmad
committed
style formatting
1 parent 981f444 commit e5ef201

File tree

85 files changed

+11311
-12852
lines changed

Some content is hidden

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

85 files changed

+11311
-12852
lines changed

.editorconfig

Lines changed: 84 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,84 @@
1-
root = true
2-
3-
[*]
4-
charset = utf-8
5-
end_of_line = lf
6-
# Note: the trim_trailing_whitespace option is br0ken in visualstudio, it
7-
# simply does not follow the EditorConfig specification. Therefor you are
8-
# strongly encouraged to not rely on this setting alone, but please install
9-
# the following extension too: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer
10-
#
11-
# References:
12-
# https://developercommunity.visualstudio.com/t/EditorConfig:-trim_trailing_whitespace-d/1240174?space=8&q=trim_trailing_whitespace
13-
# https://developercommunity.visualstudio.com/t/editorconfig-trim_trailing_whitespace-on/134457?space=8&q=trim_trailing_whitespace
14-
# https://developercommunity.visualstudio.com/t/trim_trailing_whitespace-in-editorconfi/1351034?space=8&q=trim_trailing_whitespace
15-
# https://developercommunity.visualstudio.com/t/BUG:-editorconfig-trim_trailing_whitespa/953937?space=8&q=trim_trailing_whitespace
16-
trim_trailing_whitespace = true
17-
insert_final_newline = true
18-
indent_style = tab
19-
indent_size = 2
20-
21-
22-
[*.cs] # To match existing style
23-
indent_style = space
24-
indent_size = 4
25-
26-
27-
[*.yml]
28-
indent_style = space
1+
# top-most EditorConfig file
2+
root = true
3+
4+
###########################################################
5+
# Core EditorConfig Settings - Apply to ALL files
6+
###########################################################
7+
8+
[*]
9+
# Indentation and spacing
10+
indent_style = space
11+
indent_size = 4
12+
tab_width = 4
13+
14+
# Newline preferences
15+
end_of_line = crlf
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true
18+
charset = utf-8
19+
20+
###########################################################
21+
# .NET / C# Code Style Rules
22+
###########################################################
23+
24+
[*.cs]
25+
26+
#### C# Language Style Rules (csharp_style_) ####
27+
28+
# Use "var" when the type is obvious or when a tuple/anonymous type
29+
csharp_style_var_for_built_in_types = false:suggestion
30+
csharp_style_var_when_type_is_obvious = true:suggestion
31+
csharp_style_var_elsewhere = false:suggestion
32+
33+
# Use file-scoped namespaces (if targeting .NET 6+)
34+
csharp_style_namespace_declarations = file_scoped:warning
35+
36+
# Use pattern matching for 'is' and 'switch'
37+
csharp_style_pattern_matching_over_is_with_not_null = true:suggestion
38+
csharp_style_pattern_matching_over_as = true:suggestion
39+
csharp_style_prefer_switch_expression = true:suggestion
40+
41+
# Use explicit type for arrays
42+
csharp_style_explicit_array_type = true:suggestion
43+
44+
# Use simplified accessors (e.g., private set)
45+
csharp_style_expression_bodied_accessors = false:suggestion
46+
csharp_style_expression_bodied_properties = false:suggestion
47+
csharp_style_expression_bodied_methods = false:suggestion
48+
49+
# Prefer to use `_` or `this.` for member access
50+
csharp_prefer_static_local_function = true:suggestion
51+
csharp_style_qualification_for_field = false:suggestion
52+
csharp_style_qualification_for_property = false:suggestion
53+
csharp_style_qualification_for_method = false:suggestion
54+
csharp_style_qualification_for_event = false:suggestion
55+
56+
# Prefer throwing an exception over returning null (if applicable)
57+
csharp_style_throw_expression = true:suggestion
58+
59+
#### .NET Language Style Rules (dotnet_style_) ####
60+
61+
# Use 'using' declarations instead of using statements
62+
dotnet_style_prefer_dispose_pattern = true:suggestion
63+
64+
# Prefer collection expressions for arrays and lists (if targeting C# 12+)
65+
dotnet_style_prefer_collection_expression = true:suggestion
66+
67+
# Prefer to use C# built-in type names (e.g., 'int' instead of 'Int32')
68+
dotnet_style_predefined_type_names = true:suggestion
69+
70+
#### Formatting Rules (csharp_space_, csharp_indent_) ####
71+
72+
# Control spacing around binary operators (e.g., `a = b` vs `a=b`)
73+
csharp_space_around_binary_operators = true:suggestion
74+
75+
# Control space within parentheses (e.g., `( a )` vs `(a)`)
76+
csharp_space_within_parentheses = false:suggestion
77+
78+
# Control new line for braces (e.g., `if () {` vs `if () \n {`)
79+
csharp_new_line_before_open_brace = all:suggestion
80+
csharp_new_line_before_members_in_classes = true:suggestion
81+
csharp_new_line_before_members_in_structs = true:suggestion
82+
83+
# Ensure using directives are sorted alphabetically
84+
csharp_using_directive_placement = inside_namespace:suggestion
Lines changed: 82 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,82 @@
1-
using SqlKata.Compilers;
2-
using SqlKata.Tests.Infrastructure;
3-
using Xunit;
4-
5-
namespace SqlKata.Tests
6-
{
7-
public class AggregateTests : TestSupport
8-
{
9-
[Fact]
10-
public void Count()
11-
{
12-
var query = new Query("A").AsCount();
13-
14-
var c = Compile(query);
15-
16-
Assert.Equal("SELECT COUNT(*) AS [count] FROM [A]", c[EngineCodes.SqlServer]);
17-
Assert.Equal("SELECT COUNT(*) AS `count` FROM `A`", c[EngineCodes.MySql]);
18-
Assert.Equal("SELECT COUNT(*) AS \"count\" FROM \"A\"", c[EngineCodes.PostgreSql]);
19-
Assert.Equal("SELECT COUNT(*) AS \"COUNT\" FROM \"A\"", c[EngineCodes.Firebird]);
20-
}
21-
22-
[Fact]
23-
public void CountMultipleColumns()
24-
{
25-
var query = new Query("A").AsCount(new[] { "ColumnA", "ColumnB" });
26-
27-
var c = Compile(query);
28-
29-
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT 1 FROM [A] WHERE [ColumnA] IS NOT NULL AND [ColumnB] IS NOT NULL) AS [countQuery]", c[EngineCodes.SqlServer]);
30-
}
31-
32-
[Fact]
33-
public void DistinctCount()
34-
{
35-
var query = new Query("A").Distinct().AsCount();
36-
37-
var c = Compile(query);
38-
39-
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT * FROM [A]) AS [countQuery]", c[EngineCodes.SqlServer]);
40-
}
41-
42-
[Fact]
43-
public void DistinctCountMultipleColumns()
44-
{
45-
var query = new Query("A").Distinct().AsCount(new[] { "ColumnA", "ColumnB" });
46-
47-
var c = Compile(query);
48-
49-
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT [ColumnA], [ColumnB] FROM [A]) AS [countQuery]", c[EngineCodes.SqlServer]);
50-
}
51-
52-
[Fact]
53-
public void Average()
54-
{
55-
var query = new Query("A").AsAverage("TTL");
56-
57-
var c = Compile(query);
58-
59-
Assert.Equal("SELECT AVG([TTL]) AS [avg] FROM [A]", c[EngineCodes.SqlServer]);
60-
}
61-
62-
[Fact]
63-
public void Sum()
64-
{
65-
var query = new Query("A").AsSum("PacketsDropped");
66-
67-
var c = Compile(query);
68-
69-
Assert.Equal("SELECT SUM([PacketsDropped]) AS [sum] FROM [A]", c[EngineCodes.SqlServer]);
70-
}
71-
72-
[Fact]
73-
public void Max()
74-
{
75-
var query = new Query("A").AsMax("LatencyMs");
76-
77-
var c = Compile(query);
78-
79-
Assert.Equal("SELECT MAX([LatencyMs]) AS [max] FROM [A]", c[EngineCodes.SqlServer]);
80-
}
81-
82-
[Fact]
83-
public void Min()
84-
{
85-
var query = new Query("A").AsMin("LatencyMs");
86-
87-
var c = Compile(query);
88-
89-
Assert.Equal("SELECT MIN([LatencyMs]) AS [min] FROM [A]", c[EngineCodes.SqlServer]);
90-
}
91-
}
92-
}
1+
namespace SqlKata.Tests;
2+
3+
using SqlKata.Compilers;
4+
using SqlKata.Tests.Infrastructure;
5+
using Xunit;
6+
7+
public class AggregateTests : TestSupport {
8+
[Fact]
9+
public void Count() {
10+
var query = new Query("A").AsCount();
11+
12+
var c = Compile(query);
13+
14+
Assert.Equal("SELECT COUNT(*) AS [count] FROM [A]", c[EngineCodes.SqlServer]);
15+
Assert.Equal("SELECT COUNT(*) AS `count` FROM `A`", c[EngineCodes.MySql]);
16+
Assert.Equal("SELECT COUNT(*) AS \"count\" FROM \"A\"", c[EngineCodes.PostgreSql]);
17+
Assert.Equal("SELECT COUNT(*) AS \"COUNT\" FROM \"A\"", c[EngineCodes.Firebird]);
18+
}
19+
20+
[Fact]
21+
public void CountMultipleColumns() {
22+
var query = new Query("A").AsCount(new[] { "ColumnA", "ColumnB" });
23+
24+
var c = Compile(query);
25+
26+
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT 1 FROM [A] WHERE [ColumnA] IS NOT NULL AND [ColumnB] IS NOT NULL) AS [countQuery]", c[EngineCodes.SqlServer]);
27+
}
28+
29+
[Fact]
30+
public void DistinctCount() {
31+
var query = new Query("A").Distinct().AsCount();
32+
33+
var c = Compile(query);
34+
35+
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT * FROM [A]) AS [countQuery]", c[EngineCodes.SqlServer]);
36+
}
37+
38+
[Fact]
39+
public void DistinctCountMultipleColumns() {
40+
var query = new Query("A").Distinct().AsCount(new[] { "ColumnA", "ColumnB" });
41+
42+
var c = Compile(query);
43+
44+
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT [ColumnA], [ColumnB] FROM [A]) AS [countQuery]", c[EngineCodes.SqlServer]);
45+
}
46+
47+
[Fact]
48+
public void Average() {
49+
var query = new Query("A").AsAverage("TTL");
50+
51+
var c = Compile(query);
52+
53+
Assert.Equal("SELECT AVG([TTL]) AS [avg] FROM [A]", c[EngineCodes.SqlServer]);
54+
}
55+
56+
[Fact]
57+
public void Sum() {
58+
var query = new Query("A").AsSum("PacketsDropped");
59+
60+
var c = Compile(query);
61+
62+
Assert.Equal("SELECT SUM([PacketsDropped]) AS [sum] FROM [A]", c[EngineCodes.SqlServer]);
63+
}
64+
65+
[Fact]
66+
public void Max() {
67+
var query = new Query("A").AsMax("LatencyMs");
68+
69+
var c = Compile(query);
70+
71+
Assert.Equal("SELECT MAX([LatencyMs]) AS [max] FROM [A]", c[EngineCodes.SqlServer]);
72+
}
73+
74+
[Fact]
75+
public void Min() {
76+
var query = new Query("A").AsMin("LatencyMs");
77+
78+
var c = Compile(query);
79+
80+
Assert.Equal("SELECT MIN([LatencyMs]) AS [min] FROM [A]", c[EngineCodes.SqlServer]);
81+
}
82+
}

0 commit comments

Comments
 (0)