diff --git a/.editorconfig b/.editorconfig
index 31f65393..cd5c873f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -20,183 +20,14 @@ dotnet_diagnostic.SA1600.severity = none # SA1600: Elements should be documented
dotnet_diagnostic.SA1629.severity = none # SA1629: Documentation text should end with a period
dotnet_diagnostic.SA1602.severity = none # SA1602: Enumeration items should be documented
-#### .NET Coding Conventions ####
+# SA1201: Elements should appear in the correct order
+dotnet_diagnostic.SA1201.severity = suggestion
-# Organize usings
-dotnet_separate_import_directive_groups = false
-dotnet_sort_system_directives_first = true
+# SA1202: Elements should be ordered by access
+dotnet_diagnostic.SA1202.severity = suggestion
-# this. and Me. preferences
-dotnet_style_qualification_for_event = false:suggestion
-dotnet_style_qualification_for_field = false:suggestion
-dotnet_style_qualification_for_method = false:suggestion
-dotnet_style_qualification_for_property = false:suggestion
+# SA1502: Element should not be on a single line
+dotnet_diagnostic.SA1502.severity = none
-# Language keywords vs BCL types preferences
-dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
-dotnet_style_predefined_type_for_member_access = true:suggestion
-
-# Parentheses preferences
-dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
-dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
-dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
-dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
-
-# Modifier preferences
-dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
-
-# Expression-level preferences
-dotnet_style_coalesce_expression = true:suggestion
-dotnet_style_collection_initializer = true:suggestion
-dotnet_style_explicit_tuple_names = true:suggestion
-dotnet_style_null_propagation = true:suggestion
-dotnet_style_object_initializer = true:suggestion
-dotnet_style_prefer_auto_properties = true:suggestion
-dotnet_style_prefer_compound_assignment = true:suggestion
-dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
-dotnet_style_prefer_conditional_expression_over_return = true:suggestion
-dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
-dotnet_style_prefer_inferred_tuple_names = true:suggestion
-dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
-
-# Field preferences
-dotnet_style_readonly_field = true:suggestion
-
-# Parameter preferences
-dotnet_code_quality_unused_parameters = all:suggestion
-
-#### C# Coding Conventions ####
-
-# var preferences
-csharp_style_var_elsewhere = true:suggestion
-csharp_style_var_for_built_in_types = true:suggestion
-csharp_style_var_when_type_is_apparent = true:suggestion
-
-# Expression-bodied members
-csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
-csharp_style_expression_bodied_constructors = false:suggestion
-csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
-csharp_style_expression_bodied_lambdas = true:silent
-csharp_style_expression_bodied_local_functions = true:silent
-csharp_style_expression_bodied_methods = when_on_single_line:suggestion
-csharp_style_expression_bodied_operators = when_on_single_line:suggestion
-csharp_style_expression_bodied_properties = when_on_single_line:suggestion
-
-# Pattern matching preferences
-csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
-csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
-csharp_style_prefer_switch_expression = true:suggestion
-
-# Null-checking preferences
-csharp_style_conditional_delegate_call = true:suggestion
-
-# Modifier preferences
-csharp_prefer_static_local_function = true:suggestion
-csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
-
-# Code-block preferences
-csharp_prefer_braces = when_multiline:suggestion
-csharp_prefer_simple_using_statement = true:suggestion
-
-# Expression-level preferences
-csharp_prefer_simple_default_expression = true:suggestion
-csharp_style_deconstructed_variable_declaration = true:suggestion
-csharp_style_inlined_variable_declaration = true:suggestion
-csharp_style_pattern_local_over_anonymous_function = true:suggestion
-csharp_style_prefer_index_operator = true:suggestion
-csharp_style_prefer_range_operator = true:suggestion
-csharp_style_throw_expression = true:suggestion
-csharp_style_unused_value_assignment_preference = discard_variable:suggestion
-csharp_style_unused_value_expression_statement_preference = discard_variable:silent
-
-# 'using' directive preferences
-csharp_using_directive_placement = outside_namespace:silent
-
-#### C# Formatting Rules ####
-
-# New line preferences
-csharp_new_line_before_catch = true
-csharp_new_line_before_else = true
-csharp_new_line_before_finally = true
-csharp_new_line_before_members_in_anonymous_types = true
-csharp_new_line_before_members_in_object_initializers = true
-csharp_new_line_before_open_brace = all
-csharp_new_line_between_query_expression_clauses = true
-
-# Indentation preferences
-csharp_indent_block_contents = true
-csharp_indent_braces = false
-csharp_indent_case_contents = true
-csharp_indent_case_contents_when_block = true
-csharp_indent_labels = no_change
-csharp_indent_switch_labels = true
-
-# Space preferences
-csharp_space_after_cast = false
-csharp_space_after_colon_in_inheritance_clause = true
-csharp_space_after_comma = true
-csharp_space_after_dot = false
-csharp_space_after_keywords_in_control_flow_statements = true
-csharp_space_after_semicolon_in_for_statement = true
-csharp_space_around_binary_operators = before_and_after
-csharp_space_around_declaration_statements = false
-csharp_space_before_colon_in_inheritance_clause = true
-csharp_space_before_comma = false
-csharp_space_before_dot = false
-csharp_space_before_open_square_brackets = false
-csharp_space_before_semicolon_in_for_statement = false
-csharp_space_between_empty_square_brackets = false
-csharp_space_between_method_call_empty_parameter_list_parentheses = false
-csharp_space_between_method_call_name_and_opening_parenthesis = false
-csharp_space_between_method_call_parameter_list_parentheses = false
-csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
-csharp_space_between_method_declaration_name_and_open_parenthesis = false
-csharp_space_between_method_declaration_parameter_list_parentheses = false
-csharp_space_between_parentheses = false
-csharp_space_between_square_brackets = false
-
-# Wrapping preferences
-csharp_preserve_single_line_blocks = true
-csharp_preserve_single_line_statements = false
-
-#### Naming styles ####
-
-# Naming rules
-
-dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
-dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
-dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
-
-dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
-dotnet_naming_rule.types_should_be_pascal_case.symbols = types
-dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
-
-dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
-dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
-dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
-
-# Symbol specifications
-
-dotnet_naming_symbols.interface.applicable_kinds = interface
-dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
-dotnet_naming_symbols.interface.required_modifiers =
-
-dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
-dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
-dotnet_naming_symbols.types.required_modifiers =
-
-dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
-dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
-dotnet_naming_symbols.non_field_members.required_modifiers =
-
-# Naming styles
-
-dotnet_naming_style.pascal_case.required_prefix =
-dotnet_naming_style.pascal_case.required_suffix =
-dotnet_naming_style.pascal_case.word_separator =
-dotnet_naming_style.pascal_case.capitalization = pascal_case
-
-dotnet_naming_style.begins_with_i.required_prefix = I
-dotnet_naming_style.begins_with_i.required_suffix =
-dotnet_naming_style.begins_with_i.word_separator =
-dotnet_naming_style.begins_with_i.capitalization = pascal_case
+# SA1204: Static elements should appear before instance elements
+dotnet_diagnostic.SA1204.severity = suggestion
diff --git a/ClickHouse.Client/ADO/ClickHouseCommand.cs b/ClickHouse.Client/ADO/ClickHouseCommand.cs
index e756e6db..4e268188 100644
--- a/ClickHouse.Client/ADO/ClickHouseCommand.cs
+++ b/ClickHouse.Client/ADO/ClickHouseCommand.cs
@@ -9,7 +9,6 @@
namespace ClickHouse.Client.ADO
{
-
internal class ClickHouseCommand : DbCommand
{
private readonly ClickHouseConnection dbConnection;
diff --git a/ClickHouse.Client/ADO/ClickHouseConnection.cs b/ClickHouse.Client/ADO/ClickHouseConnection.cs
index 7d570b9e..11ebc340 100644
--- a/ClickHouse.Client/ADO/ClickHouseConnection.cs
+++ b/ClickHouse.Client/ADO/ClickHouseConnection.cs
@@ -17,8 +17,8 @@ namespace ClickHouse.Client.ADO
{
public class ClickHouseConnection : DbConnection, ICloneable
{
- private static readonly HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
- private static readonly HttpClient httpClient = new HttpClient(handler);
+ private static readonly HttpClientHandler HttpClientHandler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
+ private static readonly HttpClient HttpClient = new HttpClient(HttpClientHandler);
private ConnectionState state = ConnectionState.Closed;
private string serverVersion;
@@ -40,7 +40,7 @@ public ClickHouseConnection(string connectionString)
}
///
- /// String defining connection settings for ClickHouse server
+ /// Gets or sets string defining connection settings for ClickHouse server
/// Example: Host=localhost;Port=8123;Username=default;Password=123;Compression=true
///
public sealed override string ConnectionString
@@ -56,7 +56,7 @@ public sealed override string ConnectionString
Port = (ushort)serverUri?.Port,
Driver = Driver,
Compression = useCompression,
- UseSession = session != null
+ UseSession = session != null,
};
return builder.ToString();
}
@@ -103,7 +103,7 @@ internal async Task PostSqlQueryAsync(string sqlQuery, Canc
}
postMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("text/sql");
- var response = await httpClient.SendAsync(postMessage, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
+ var response = await HttpClient.SendAsync(postMessage, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
return await HandleError(response, sqlQuery).ConfigureAwait(false);
}
@@ -117,7 +117,7 @@ internal async Task PostBulkDataAsync(string sql, Stream da
if (isCompressed)
postMessage.Content.Headers.Add("Content-Encoding", "gzip");
- var response = await httpClient.SendAsync(postMessage, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
+ var response = await HttpClient.SendAsync(postMessage, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
return await HandleError(response, sql).ConfigureAwait(false);
}
@@ -139,7 +139,7 @@ private string MakeUri(string sql = null)
Database = database,
UseHttpCompression = useCompression,
SqlQuery = sql,
- SessionId = session
+ SessionId = session,
};
uriBuilder.Query = queryParameters.ToString();
diff --git a/ClickHouse.Client/ADO/Readers/ClickHouseBinaryReader.cs b/ClickHouse.Client/ADO/Readers/ClickHouseBinaryReader.cs
index c71f4cfe..e05b7116 100644
--- a/ClickHouse.Client/ADO/Readers/ClickHouseBinaryReader.cs
+++ b/ClickHouse.Client/ADO/Readers/ClickHouseBinaryReader.cs
@@ -8,7 +8,7 @@ namespace ClickHouse.Client.ADO.Readers
{
internal class ClickHouseBinaryReader : ClickHouseDataReader
{
- private const int bufferSize = 512 * 1024;
+ private const int BufferSize = 512 * 1024;
private readonly ExtendedBinaryReader reader;
private readonly BinaryStreamReader streamReader;
@@ -16,7 +16,7 @@ internal class ClickHouseBinaryReader : ClickHouseDataReader
public ClickHouseBinaryReader(HttpResponseMessage httpResponse)
: base(httpResponse)
{
- var stream = new BufferedStream(httpResponse.Content.ReadAsStreamAsync().GetAwaiter().GetResult(), bufferSize);
+ var stream = new BufferedStream(httpResponse.Content.ReadAsStreamAsync().GetAwaiter().GetResult(), BufferSize);
reader = new ExtendedBinaryReader(stream); // will dispose of stream
streamReader = new BinaryStreamReader(reader);
ReadHeaders();
@@ -67,4 +67,4 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}
}
-}
\ No newline at end of file
+}
diff --git a/ClickHouse.Client/ADO/Readers/ClickHouseJsonCompactReader.cs b/ClickHouse.Client/ADO/Readers/ClickHouseJsonCompactReader.cs
index 2c4abfa5..6f97515a 100644
--- a/ClickHouse.Client/ADO/Readers/ClickHouseJsonCompactReader.cs
+++ b/ClickHouse.Client/ADO/Readers/ClickHouseJsonCompactReader.cs
@@ -65,10 +65,10 @@ private void ReadHeaders()
private class JsonColumnRecord
{
[JsonProperty("name")]
- public readonly string Name;
+ public string Name { get; }
[JsonProperty("type")]
- public readonly string Type;
+ public string Type { get; }
[JsonConstructor]
public JsonColumnRecord(string name, string type)
@@ -80,13 +80,13 @@ public JsonColumnRecord(string name, string type)
private void AssertEquals(T expected, T actual)
{
- Debug.Assert(Equals(expected, actual));
+ Debug.Assert(Equals(expected, actual), "Comparison failed");
if (!Equals(expected, actual))
throw new InvalidOperationException($"Error: expected {expected}, got {actual}");
}
///
- /// Streams
+ /// Reads next row of JSON from input stream
///
/// Whether read was successful
public override bool Read()
@@ -134,4 +134,4 @@ private object TryConvertTo(object data, ClickHouseType type)
return data;
}
}
-}
\ No newline at end of file
+}
diff --git a/ClickHouse.Client/ClickHouseConnectionDriver.cs b/ClickHouse.Client/ClickHouseConnectionDriver.cs
index bc0863b1..169c6142 100644
--- a/ClickHouse.Client/ClickHouseConnectionDriver.cs
+++ b/ClickHouse.Client/ClickHouseConnectionDriver.cs
@@ -4,6 +4,6 @@ public enum ClickHouseConnectionDriver
{
Binary,
JSON,
- TSV
+ TSV,
}
}
diff --git a/ClickHouse.Client/Formats/BinaryStreamReader.cs b/ClickHouse.Client/Formats/BinaryStreamReader.cs
index 59c5d13d..ec46eddf 100644
--- a/ClickHouse.Client/Formats/BinaryStreamReader.cs
+++ b/ClickHouse.Client/Formats/BinaryStreamReader.cs
@@ -128,7 +128,6 @@ public object ReadValue(ClickHouseType databaseType, bool nullAsDbNull)
case ClickHouseTypeCode.LowCardinality:
var lcCardinality = (LowCardinalityType)databaseType;
return ReadValue(lcCardinality.UnderlyingType, nullAsDbNull);
-
}
throw new NotImplementedException($"Reading of {databaseType.TypeCode} is not implemented");
}
diff --git a/ClickHouse.Client/Formats/BinaryStreamWriter.cs b/ClickHouse.Client/Formats/BinaryStreamWriter.cs
index 72a600dc..1e077e36 100644
--- a/ClickHouse.Client/Formats/BinaryStreamWriter.cs
+++ b/ClickHouse.Client/Formats/BinaryStreamWriter.cs
@@ -193,7 +193,7 @@ private static Guid ExtractGuid(object data)
else if (data is string s)
guid = new Guid(s);
else
- throw new NotSupportedException($"Cannot convert {data?.GetType()?.Name ?? "null"} to GUID");
+ throw new ArgumentException($"Cannot convert {data?.GetType()?.Name ?? "null"} to GUID");
return guid;
}
@@ -205,7 +205,7 @@ private static IPAddress ExtractIPAddress(object data)
else if (data is string s)
address = IPAddress.Parse(s);
else
- throw new NotSupportedException($"Cannot convert {data?.GetType()?.Name ?? "null"} to IPv4");
+ throw new ArgumentException($"Cannot convert {data?.GetType()?.Name ?? "null"} to IPv4");
return address;
}
}
diff --git a/ClickHouse.Client/Types/ArrayType.cs b/ClickHouse.Client/Types/ArrayType.cs
index 7a1a9053..f1819c63 100644
--- a/ClickHouse.Client/Types/ArrayType.cs
+++ b/ClickHouse.Client/Types/ArrayType.cs
@@ -20,7 +20,7 @@ public override ParameterizedType Parse(string typeName, Func ClickHouseTypeCode.DateTime;
@@ -60,7 +59,7 @@ public override ParameterizedType Parse(string typeName, Func ClickHouseTypeCode.Decimal;
///
- /// Size of type in bytes
+ /// Gets size of type in bytes
///
public virtual int Size => Precision switch
{
diff --git a/ClickHouse.Client/Types/EnumType.cs b/ClickHouse.Client/Types/EnumType.cs
index c45f5beb..24c83f2e 100644
--- a/ClickHouse.Client/Types/EnumType.cs
+++ b/ClickHouse.Client/Types/EnumType.cs
@@ -29,7 +29,7 @@ public override ParameterizedType Parse(string typeName, Func simpleTypes = new Dictionary();
- private static readonly IDictionary parameterizedTypes = new Dictionary();
- private static readonly IDictionary reverseMapping = new Dictionary();
+ private static readonly IDictionary SimpleTypes = new Dictionary();
+ private static readonly IDictionary ParameterizedTypes = new Dictionary();
+ private static readonly IDictionary ReverseMapping = new Dictionary();
static TypeConverter()
{
@@ -39,11 +39,10 @@ static TypeConverter()
RegisterPlainTypeInfo(ClickHouseTypeCode.IPv4);
RegisterPlainTypeInfo(ClickHouseTypeCode.IPv6);
-
// Special 'nothing' type
var nti = new NothingType();
- simpleTypes.Add(ClickHouseTypeCode.Nothing, nti);
- reverseMapping.Add(typeof(DBNull), nti);
+ SimpleTypes.Add(ClickHouseTypeCode.Nothing, nti);
+ ReverseMapping.Add(typeof(DBNull), nti);
// complex types like FixedString/Array/Nested etc.
RegisterParameterizedType();
@@ -66,8 +65,8 @@ static TypeConverter()
RegisterParameterizedType();
RegisterParameterizedType();
- reverseMapping.Add(typeof(decimal), new Decimal128Type());
- reverseMapping.Add(typeof(DateTime), new DateTimeType());
+ ReverseMapping.Add(typeof(decimal), new Decimal128Type());
+ ReverseMapping.Add(typeof(DateTime), new DateTimeType());
RegisterPlainTypeInfo(ClickHouseTypeCode.Date);
}
@@ -75,28 +74,28 @@ static TypeConverter()
private static void RegisterPlainTypeInfo(ClickHouseTypeCode type)
{
var typeInfo = new PlainDataType(type);
- simpleTypes.Add(type, typeInfo);
- if (!reverseMapping.ContainsKey(typeInfo.FrameworkType))
- reverseMapping.Add(typeInfo.FrameworkType, typeInfo);
+ SimpleTypes.Add(type, typeInfo);
+ if (!ReverseMapping.ContainsKey(typeInfo.FrameworkType))
+ ReverseMapping.Add(typeInfo.FrameworkType, typeInfo);
}
private static void RegisterParameterizedType()
where T : ParameterizedType, new()
{
var t = new T();
- parameterizedTypes.Add(t.Name, t);
+ ParameterizedTypes.Add(t.Name, t);
}
public static ClickHouseType ParseClickHouseType(string type)
{
- if (Enum.TryParse(type, out var chType) && simpleTypes.TryGetValue(chType, out var typeInfo))
+ if (Enum.TryParse(type, out var chType) && SimpleTypes.TryGetValue(chType, out var typeInfo))
return typeInfo;
var index = type.IndexOf('(');
var parameterizedTypeName = index > 0 ? type.Substring(0, index) : type;
- if (parameterizedTypes.ContainsKey(parameterizedTypeName))
- return parameterizedTypes[parameterizedTypeName].Parse(type, ParseClickHouseType);
+ if (ParameterizedTypes.ContainsKey(parameterizedTypeName))
+ return ParameterizedTypes[parameterizedTypeName].Parse(type, ParseClickHouseType);
throw new ArgumentOutOfRangeException(nameof(type), "Unknown type: " + type);
}
@@ -108,8 +107,8 @@ public static ClickHouseType ParseClickHouseType(string type)
/// Corresponding ClickHouse type
public static ClickHouseType ToClickHouseType(Type type)
{
- if (reverseMapping.ContainsKey(type))
- return reverseMapping[type];
+ if (ReverseMapping.ContainsKey(type))
+ return ReverseMapping[type];
if (type.IsArray)
return new ArrayType() { UnderlyingType = ToClickHouseType(type.GetElementType()) };