Skip to content

Commit

Permalink
Merge pull request PostgreSQLCopyHelper#43 from say25/2.5.0-alpha
Browse files Browse the repository at this point in the history
Merge Latest Changes From Master
  • Loading branch information
bytefish authored Jun 9, 2019
2 parents 8b93ccf + 3aca910 commit 07ba6a4
Show file tree
Hide file tree
Showing 26 changed files with 337 additions and 173 deletions.
177 changes: 177 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
root = true

# From https://github.com/dotnet/roslyn/blob/master/.editorconfig (with additions)
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
# EditorConfig is awesome:http://EditorConfig.org

# top-most EditorConfig file
root = true

# Don't use tabs for indentation.
[*]
indent_style = space
# Please don't specify the following here, as they have too many unintended consequences:
# - indent_size
# - insert_final_newline
# - charset
# - trim_trailing_whitespace

[*.{yml,yaml,tf}]
indent_size = 2

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom
trim_trailing_whitespace = true

# Visual Studio solution files
[*.sln]
# Both VS2017/dotnet tooling do it this way:
# - UTF-8 with BOM
# - tabs (size 4) - yes, it actually uses tabs.
# - final newline
# While BOM is discouraged, as all tooling appears to agree on its format, we use it here.
indent_size = 4
indent_style = tab
charset = utf-8-bom
trim_trailing_whitespace = true

# Xml project files
# dotnet/VS2017 tooling agree on:
# - 2-space indent
# - UTF-8
# dotnet/VS2017 tooling disagreeon:
# - BOM: dotnet no, VS2017 yes
# Conclusion: do not enforce bom/no-bom
# - no final newline: dotnet no, VS2017 yes
# Conclusion: do not enforce
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,dcproj}]
indent_size = 2
trim_trailing_whitespace = true

# Xml config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
insert_final_newline = false
trim_trailing_whitespace = true

# Standard XML files
[*.{xml,xslt,xsd}]
indent_size = 2
trim_trailing_whitespace = true

# JSON files
[*.json]
indent_size = 2
trim_trailing_whitespace = true

# Markdown files
# NOTE: Markdown trailing whitespace is significant.
# @see https://github.com/Microsoft/vscode/issues/1679
[*.{md,markdown}]
indent_size = 4
trim_trailing_whitespace = false

# Dotnet code style settings:
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# Prefer accessibility modifiers to be declared except for public interface members.
# This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning

# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

# CSharp code style settings:
[*.cs]
# csharp_preferred_modifier_order =
# public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
csharp_preferred_modifier_order = csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

# Prefer method-like constructs to have an expression body, when they will be a single line
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
csharp_style_expression_bodied_operators = when_on_single_line:suggestion

# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion

# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Prefer curly braces even for one line of code
csharp_prefer_braces = true:warning

# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Indentation settings
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = no_change

# Spacing settings
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_parentheses = false

# Wrapping settings
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true

# Naming conventions
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions

# Public members must be capitalized (public_members_must_be_capitalized)
[*.{cs,vb}]
dotnet_naming_rule.public_members_must_be_capitalized.symbols = public_symbols
dotnet_naming_symbols.public_symbols.applicable_kinds = property,method,field,event,delegate
dotnet_naming_symbols.public_symbols.applicable_accessibilities = public
dotnet_naming_symbols.public_symbols.required_modifiers = readonly

dotnet_naming_rule.public_members_must_be_capitalized.style = first_word_upper_case_style
dotnet_naming_style.first_word_upper_case_style.capitalization = first_word_upper

dotnet_naming_rule.public_members_must_be_capitalized.severity = suggestion
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Philipp Wagner. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Npgsql;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Npgsql;
using NUnit.Framework;
using PostgreSQLCopyHelper.Test.Extensions;

namespace PostgreSQLCopyHelper.Test
Expand Down Expand Up @@ -51,7 +51,7 @@ private class StringArrayEntity
public String[] Array { get; set; }
}


[Test]
public void Test_StringArray()
{
Expand All @@ -78,7 +78,7 @@ public void Test_StringArray()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (String[])result[0][0];
var resultArray = (String[]) result[0][0];

Assert.AreEqual("A", resultArray[0]);
Assert.AreEqual("B", resultArray[1]);
Expand Down Expand Up @@ -109,7 +109,7 @@ public void Test_Int16Array()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (Int16[])result[0][0];
var resultArray = (Int16[]) result[0][0];

Assert.AreEqual(1, resultArray[0]);
Assert.AreEqual(2, resultArray[1]);
Expand All @@ -126,7 +126,7 @@ public void Test_Int32Array()

var entity0 = new Int32ArrayEntity()
{
Array = new [] { 1, 2 }
Array = new[] { 1, 2 }
};

subject.SaveAll(connection, new[] { entity0 });
Expand All @@ -140,7 +140,7 @@ public void Test_Int32Array()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (Int32[])result[0][0];
var resultArray = (Int32[]) result[0][0];

Assert.AreEqual(1, resultArray[0]);
Assert.AreEqual(2, resultArray[1]);
Expand Down Expand Up @@ -172,7 +172,7 @@ public void Test_Int64Array()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (Int64[])result[0][0];
var resultArray = (Int64[]) result[0][0];

Assert.AreEqual(1, resultArray[0]);
Assert.AreEqual(2, resultArray[1]);
Expand All @@ -192,7 +192,7 @@ public void Test_DecimalArray()
Array = new Decimal[] { 1, 2 }
};

subject.SaveAll(connection, new [] { entity0 });
subject.SaveAll(connection, new[] { entity0 });

var result = GetAll();

Expand All @@ -203,7 +203,7 @@ public void Test_DecimalArray()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (Decimal[])result[0][0];
var resultArray = (Decimal[]) result[0][0];

Assert.AreEqual(1, resultArray[0]);
Assert.AreEqual(2, resultArray[1]);
Expand Down Expand Up @@ -234,7 +234,7 @@ public void Test_SingleArray()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (Single[])result[0][0];
var resultArray = (Single[]) result[0][0];

Assert.AreEqual(1.32f, resultArray[0], 1e-5);
Assert.AreEqual(2.124f, resultArray[1], 1e-5);
Expand Down Expand Up @@ -265,7 +265,7 @@ public void Test_DoubleArray()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (Double[])result[0][0];
var resultArray = (Double[]) result[0][0];

Assert.AreEqual(1.32, resultArray[0], 1e-5);
Assert.AreEqual(2.124, resultArray[1], 1e-5);
Expand All @@ -282,12 +282,12 @@ public void Test_ByteArrayArray()

var entity0 = new ByteArrayArrayEntity()
{
Array = new byte[][] { new byte[] {1, 2} }
Array = new byte[][] { new byte[] { 1, 2 } }
};

subject.SaveAll(connection, new[] { entity0 });

var result = GetAll();
var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(1, result.Count);
Expand All @@ -296,7 +296,7 @@ public void Test_ByteArrayArray()
Assert.IsNotNull(result[0][0]);

// And now check the values:
var resultArray = (byte[][])result[0][0];
var resultArray = (byte[][]) result[0][0];

Assert.AreEqual(1, resultArray[0][0]);
Assert.AreEqual(2, resultArray[0][1]);
Expand All @@ -305,7 +305,7 @@ public void Test_ByteArrayArray()

private int CreateTable(string arrayType)
{
var sqlStatement = string.Format("CREATE TABLE sample.unit_test(col_array {0}[]);", arrayType);
var sqlStatement = $"CREATE TABLE sample.unit_test(col_array {arrayType}[]);";

var sqlCommand = new NpgsqlCommand(sqlStatement, connection);

Expand Down
Loading

0 comments on commit 07ba6a4

Please sign in to comment.