From 42eb936248ad12c3fc7ba8e7026c35deba7d0e28 Mon Sep 17 00:00:00 2001 From: MareMare Date: Thu, 6 Jun 2024 11:01:47 +0900 Subject: [PATCH] Update `.editorconfig` and correct code (#33) --- .editorconfig | 561 ++++++++---------- README.md | 4 + src/Disposable.cs | 4 +- src/ExcelToA5er.csproj | 19 +- src/MainForm.cs | 87 +-- .../ClosedXmlExtensions.cs | 56 +- .../ColumnDefinition.cs | 4 +- .../TableDefinition.cs | 4 +- .../XlsxInformation.Loader.cs | 2 +- .../XlsxInformation.cs | 6 +- src/Program.cs | 3 +- src/Progress/ProgressForm.cs | 11 +- src/Progress/ProgressInfo.cs | 2 +- src/Progress/ProgressReporter.cs | 2 +- ...Template.cs => A5ErRuntimeTextTemplate.cs} | 42 +- ....cs => A5ErRuntimeTextTemplate.partial.cs} | 10 +- ...Template.tt => A5ErRuntimeTextTemplate.tt} | 0 17 files changed, 375 insertions(+), 442 deletions(-) rename src/{Metadatas => Metadata}/ClosedXmlExtensions.cs (77%) rename src/{Metadatas => Metadata}/ColumnDefinition.cs (97%) rename src/{Metadatas => Metadata}/TableDefinition.cs (95%) rename src/{Metadatas => Metadata}/XlsxInformation.Loader.cs (98%) rename src/{Metadatas => Metadata}/XlsxInformation.cs (91%) rename src/Templates/{A5erRuntimeTextTemplate.cs => A5ErRuntimeTextTemplate.cs} (93%) rename src/Templates/{A5erRuntimeTextTemplate.partial.cs => A5ErRuntimeTextTemplate.partial.cs} (86%) rename src/Templates/{A5erRuntimeTextTemplate.tt => A5ErRuntimeTextTemplate.tt} (100%) diff --git a/.editorconfig b/.editorconfig index 2cbc184..baa2bf4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,278 +1,196 @@ -# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Users\maref\Documents\Github\hsc-m-fujii\Histogram\src codebase based on best match to current usage at 2021/11/26 -# You can modify the rules from these initially generated values to suit your own policies -# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -[*.cs] +# 上位ディレクトリから .editorconfig 設定を継承する場合は、以下の行を削除します +root = true +# C# ファイル +[*.cs] -#Core editorconfig formatting - indentation +#### コア EditorConfig オプション #### -#use soft tabs (spaces) for indentation +# インデントと間隔 +indent_size = 4 indent_style = space +tab_width = 4 -#Formatting - new line options - -#place else statements on a new line -csharp_new_line_before_else = true -#require finally statements to be on a new line after the closing brace -csharp_new_line_before_finally = true -#require members of anonymous types to be on the same line -csharp_new_line_before_members_in_anonymous_types =true -#require members of object initializers to be on the same line -csharp_new_line_before_members_in_object_initializers =true -#require braces to be on a new line for methods, control_blocks, types, lambdas, properties, and accessors (also known as "Allman" style) -csharp_new_line_before_open_brace =all +# 改行設定 +end_of_line = crlf +insert_final_newline = false -#Formatting - organize using options +#### .NET コーディング規則 #### -#sort System.* using directives alphabetically, and place them before other usings +# using の整理 +dotnet_separate_import_directive_groups = false dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. と Me. の設定 +dotnet_style_qualification_for_event = true:warning +dotnet_style_qualification_for_field = true +dotnet_style_qualification_for_method = true:warning +dotnet_style_qualification_for_property = true:warning + +# 言語キーワードと BCL の種類の設定 +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# かっこの設定 +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# 修飾子設定 +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# 式レベルの設定 +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_collection_expression = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# フィールド設定 +dotnet_style_readonly_field = true + +# パラメーターの設定 +dotnet_code_quality_unused_parameters = all + +# 抑制の設定 +dotnet_remove_unnecessary_suppression_exclusions = none + +# 改行設定 +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = false:warning + +#### C# コーディング規則 #### + +# var を優先 +csharp_style_var_elsewhere = true:suggestion +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion -#Formatting - spacing options +# 式のようなメンバー +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = true:suggestion +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# パターン マッチング設定 +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_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:suggestion +csharp_style_prefer_switch_expression = true:suggestion + +# Null チェック設定 +csharp_style_conditional_delegate_call = true:suggestion + +# 修飾子設定 +csharp_prefer_static_local_function = true:suggestion +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion + +# コード ブロックの設定 +csharp_prefer_braces = true:warning +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_method_group_conversion = true:suggestion +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent + +# 式レベルの設定 +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = 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' ディレクティブの基本設定 +csharp_using_directive_placement = outside_namespace:suggestion + +# 改行設定 +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:warning +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent +csharp_style_allow_embedded_statements_on_same_line_experimental = false:warning + +#### C# 書式ルール #### + +# 改行設定 +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 + +# インデント設定 +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true -#require NO space between a cast and the value +# スペース設定 csharp_space_after_cast = false -#require a space before the colon for bases or interfaces in a type declaration csharp_space_after_colon_in_inheritance_clause = true -#require a space after a keyword in a control flow statement such as a for loop +csharp_space_after_comma = true +csharp_space_after_dot = false csharp_space_after_keywords_in_control_flow_statements = true -#require a space before the colon for bases or interfaces in a type declaration +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 -#remove space within empty argument list parentheses +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 -#remove space between method call name and opening parenthesis csharp_space_between_method_call_name_and_opening_parenthesis = false -#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call csharp_space_between_method_call_parameter_list_parentheses = false -#remove space within empty parameter list parentheses for a method declaration csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. +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 -#Formatting - wrapping options - -#leave code block on single line +# 折り返しの設定 csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true -#Style - Code block preferences - -#prefer curly braces even for one line of code -csharp_prefer_braces = true:suggestion - -#Style - expression bodied member options - -#prefer expression-bodied members for accessors -csharp_style_expression_bodied_accessors = true:suggestion -#prefer expression-bodied members for methods -csharp_style_expression_bodied_methods = true:suggestion -#prefer expression-bodied members for properties -csharp_style_expression_bodied_properties = true:suggestion - -#Style - expression level options - -#prefer out variables to be declared inline in the argument list of a method call when possible -csharp_style_inlined_variable_declaration = true:suggestion -#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them -dotnet_style_predefined_type_for_member_access = true:suggestion - -#Style - Expression-level preferences - -#prefer objects to not be initialized using object initializers -dotnet_style_object_initializer = false:suggestion -#prefer inferred anonymous type member names -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion - -#Style - implicit and explicit types - -#prefer var over explicit type in all cases, unless overridden by another code style rule -csharp_style_var_elsewhere = true:suggestion -#prefer var is used to declare variables with built-in system types such as int -csharp_style_var_for_built_in_types = true:suggestion -#prefer var when the type is already mentioned on the right-hand side of a declaration expression -csharp_style_var_when_type_is_apparent = true:suggestion - -#Style - language keyword and framework type options - -#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion - -#Style - Miscellaneous preferences - -#prefer anonymous functions over local functions -csharp_style_pattern_local_over_anonymous_function = false:suggestion - -#Style - modifier options - -#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:suggestion - -#Style - Modifier preferences - -#when this rule is set to a list of modifiers, prefer the specified ordering. -csharp_preferred_modifier_order = public,private,internal,protected,static,readonly,async,override:suggestion - -#Style - Pattern matching - -#prefer is expression with type casts instead of pattern matching -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +#### 命名スタイル #### -#Style - qualification options - -#prefer fields not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_field = false:suggestion -#prefer methods to be prefaced with this. in C# or Me. in Visual Basic -dotnet_style_qualification_for_method = true:suggestion -#prefer properties to be prefaced with this. in C# or Me. in Visual Basic -dotnet_style_qualification_for_property = true:suggestion -insert_final_newline=true -csharp_style_expression_bodied_constructors= false:suggestion -csharp_style_expression_bodied_operators= true:silent -csharp_style_expression_bodied_indexers= true:suggestion -dotnet_diagnostic.CA1001.severity=warning -dotnet_diagnostic.CA1070.severity=warning -dotnet_diagnostic.CA1200.severity=warning -dotnet_diagnostic.CA1309.severity=warning -dotnet_diagnostic.CA1507.severity=warning -dotnet_diagnostic.CA1805.severity=warning -dotnet_diagnostic.CA1824.severity=warning -dotnet_diagnostic.CA1825.severity=warning -dotnet_diagnostic.CA1845.severity=warning -dotnet_diagnostic.CA1841.severity=warning -dotnet_diagnostic.CA2016.severity=warning -dotnet_diagnostic.SA1623.severity=silent -dotnet_diagnostic.SA1642.severity=silent -dotnet_diagnostic.SA1643.severity=silent -dotnet_diagnostic.SA1515.severity=silent -dotnet_diagnostic.SA1519.severity=silent -dotnet_diagnostic.SA1119_p.severity=warning -dotnet_diagnostic.SA1309.severity=silent -dotnet_diagnostic.SA1120.severity=silent -dotnet_diagnostic.SA1124.severity=silent -dotnet_diagnostic.SA1413.severity=silent -dotnet_diagnostic.CA2244.severity=warning -dotnet_diagnostic.CA2246.severity=warning -dotnet_diagnostic.SA1629.severity=silent -dotnet_diagnostic.SA1000.severity=suggestion -dotnet_diagnostic.SA1200.severity=silent - -[*.{cs,vb}] -dotnet_style_qualification_for_field= true:warning -dotnet_style_qualification_for_event= true:warning -dotnet_style_qualification_for_property= true:warning -dotnet_style_qualification_for_method= true:warning -dotnet_style_parentheses_in_arithmetic_binary_operators= always_for_clarity:warning -dotnet_style_parentheses_in_other_binary_operators= always_for_clarity:warning -dotnet_style_parentheses_in_relational_binary_operators= always_for_clarity:warning -dotnet_style_parentheses_in_other_operators= never_if_unnecessary:warning -dotnet_style_readonly_field= true:warning -dotnet_style_prefer_conditional_expression_over_assignment=true:warning -dotnet_style_prefer_conditional_expression_over_return=true:warning -dotnet_diagnostic.CA1000.severity=warning -dotnet_diagnostic.CA1010.severity=warning -dotnet_diagnostic.CA1016.severity=warning -dotnet_diagnostic.CA1018.severity=warning -dotnet_diagnostic.CA1041.severity=warning -dotnet_diagnostic.CA1036.severity=warning -dotnet_diagnostic.CA1050.severity=warning -dotnet_diagnostic.CA1051.severity=warning -dotnet_diagnostic.CA1061.severity=warning -dotnet_diagnostic.CA1067.severity=warning -dotnet_diagnostic.CA1068.severity=warning -dotnet_diagnostic.CA1069.severity=warning -dotnet_diagnostic.CA1304.severity=warning -dotnet_diagnostic.CA1305.severity=warning -dotnet_diagnostic.CA1310.severity=warning -dotnet_diagnostic.CA2101.severity=warning -dotnet_diagnostic.CA1401.severity=warning -dotnet_diagnostic.CA1419.severity=warning -dotnet_diagnostic.CA1707.severity=warning -dotnet_diagnostic.CA1708.severity=warning -dotnet_diagnostic.CA1710.severity=warning -dotnet_diagnostic.CA1711.severity=warning -dotnet_diagnostic.CA1712.severity=warning -dotnet_diagnostic.CA1715.severity=warning -dotnet_diagnostic.CA1720.severity=warning -dotnet_diagnostic.CA1725.severity=warning -dotnet_diagnostic.CA1727.severity=warning -dotnet_diagnostic.CA1806.severity=warning -dotnet_diagnostic.CA1821.severity=warning -dotnet_diagnostic.CA1822.severity=warning -dotnet_diagnostic.CA1826.severity=warning -dotnet_diagnostic.CA1827.severity=warning -dotnet_diagnostic.CA1828.severity=warning -dotnet_diagnostic.CA1829.severity=warning -dotnet_diagnostic.CA1830.severity=warning -dotnet_diagnostic.CA1832.severity=warning -dotnet_diagnostic.CA1848.severity=suggestion -dotnet_diagnostic.CA1847.severity=warning -dotnet_diagnostic.CA1846.severity=warning -dotnet_diagnostic.CA1844.severity=warning -dotnet_diagnostic.CA1833.severity=warning -dotnet_diagnostic.CA1834.severity=warning -dotnet_diagnostic.CA1835.severity=warning -dotnet_diagnostic.CA1836.severity=warning -dotnet_diagnostic.CA1837.severity=warning -dotnet_diagnostic.CA1838.severity=warning -dotnet_diagnostic.CA1839.severity=warning -dotnet_diagnostic.CA1840.severity=warning -dotnet_diagnostic.CA1842.severity=warning -dotnet_diagnostic.CA1843.severity=warning -dotnet_diagnostic.CA2009.severity=warning -dotnet_diagnostic.CA2011.severity=warning -dotnet_diagnostic.CA2012.severity=warning -dotnet_diagnostic.CA3061.severity=warning -dotnet_diagnostic.CA3075.severity=warning -dotnet_diagnostic.CA3076.severity=warning -dotnet_diagnostic.CA3077.severity=warning -dotnet_diagnostic.CA3147.severity=warning -dotnet_diagnostic.CA5350.severity=warning -dotnet_diagnostic.CA5351.severity=warning -dotnet_diagnostic.CA5359.severity=warning -dotnet_diagnostic.CA5360.severity=warning -dotnet_diagnostic.CA5363.severity=warning -dotnet_diagnostic.CA5364.severity=warning -dotnet_diagnostic.CA5365.severity=warning -dotnet_diagnostic.CA5366.severity=warning -dotnet_diagnostic.CA5368.severity=warning -dotnet_diagnostic.CA5369.severity=warning -dotnet_diagnostic.CA5370.severity=warning -dotnet_diagnostic.CA5371.severity=warning -dotnet_diagnostic.CA5372.severity=warning -dotnet_diagnostic.CA5373.severity=warning -dotnet_diagnostic.CA5374.severity=warning -dotnet_diagnostic.CA5379.severity=warning -dotnet_diagnostic.CA5384.severity=warning -dotnet_diagnostic.CA5385.severity=warning -dotnet_diagnostic.CA5397.severity=warning -dotnet_diagnostic.CA1816.severity=warning -dotnet_diagnostic.CA2201.severity=warning -dotnet_diagnostic.CA2208.severity=warning -dotnet_diagnostic.CA2211.severity=warning -dotnet_diagnostic.CA2215.severity=warning -dotnet_diagnostic.CA2219.severity=warning -dotnet_diagnostic.CA2229.severity=warning -dotnet_diagnostic.CA2231.severity=warning -dotnet_diagnostic.CA2241.severity=warning -dotnet_diagnostic.CA2242.severity=warning -dotnet_diagnostic.CA2253.severity=warning -dotnet_diagnostic.CA2245.severity=warning -dotnet_diagnostic.CA2248.severity=warning -dotnet_diagnostic.CA2249.severity=warning -dotnet_diagnostic.CA2250.severity=warning -dotnet_diagnostic.CA2251.severity=warning -tab_width = 4 -indent_size = 4 -dotnet_style_operator_placement_when_wrapping = beginning_of_line -end_of_line = crlf -dotnet_code_quality_unused_parameters = all:suggestion -dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_null_propagation = true:suggestion -[*.vb] -dotnet_diagnostic.CA1047.severity=warning -[*.cs] -#### �����X�^�C�� #### - -# ���O�t�����[�� +# 名前付けルール dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface @@ -286,7 +204,15 @@ 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 -# �L���̎d�l +dotnet_naming_rule.private_field_should_be_camel_case_with__.severity = suggestion +dotnet_naming_rule.private_field_should_be_camel_case_with__.symbols = private_field +dotnet_naming_rule.private_field_should_be_camel_case_with__.style = camel_case_with__ + +dotnet_naming_rule.private_readonly_field_should_be_camel_case_with__.severity = suggestion +dotnet_naming_rule.private_readonly_field_should_be_camel_case_with__.symbols = private_readonly_field +dotnet_naming_rule.private_readonly_field_should_be_camel_case_with__.style = camel_case_with__ + +# 記号の仕様 dotnet_naming_symbols.interface.applicable_kinds = interface dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected @@ -300,83 +226,72 @@ dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, meth dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected dotnet_naming_symbols.non_field_members.required_modifiers = -# �����X�^�C�� +dotnet_naming_symbols.private_field.applicable_kinds = field +dotnet_naming_symbols.private_field.applicable_accessibilities = private +dotnet_naming_symbols.private_field.required_modifiers = -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 +dotnet_naming_symbols.private_readonly_field.applicable_kinds = field +dotnet_naming_symbols.private_readonly_field.applicable_accessibilities = private +dotnet_naming_symbols.private_readonly_field.required_modifiers = readonly, static -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.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 -csharp_indent_labels = one_less_than_current -csharp_space_around_binary_operators = before_and_after -csharp_using_directive_placement = outside_namespace:silent -csharp_style_conditional_delegate_call = true:suggestion -csharp_style_prefer_parameter_null_checking = true:suggestion -csharp_prefer_simple_using_statement = true:suggestion -csharp_style_namespace_declarations = block_scoped:silent -csharp_style_prefer_method_group_conversion = true:silent -csharp_style_prefer_switch_expression = true:suggestion -csharp_style_prefer_pattern_matching = true:silent -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_prefer_not_pattern = true:suggestion -csharp_style_prefer_extended_property_pattern = true:suggestion -csharp_prefer_static_local_function = true:suggestion -csharp_style_expression_bodied_lambdas = true:silent -csharp_style_expression_bodied_local_functions = false:silent - -[*.vb] -#### �����X�^�C�� #### - -# ���O�t�����[�� - -dotnet_naming_rule.interface_should_be_i_�Ŏn�܂�.severity = suggestion -dotnet_naming_rule.interface_should_be_i_�Ŏn�܂�.symbols = interface -dotnet_naming_rule.interface_should_be_i_�Ŏn�܂�.style = i_�Ŏn�܂� - -dotnet_naming_rule.�^_should_be_�p�X�J��_�P�[�X.severity = suggestion -dotnet_naming_rule.�^_should_be_�p�X�J��_�P�[�X.symbols = �^ -dotnet_naming_rule.�^_should_be_�p�X�J��_�P�[�X.style = �p�X�J��_�P�[�X - -dotnet_naming_rule.�t�B�[���h�ȊO�̃����o�[_should_be_�p�X�J��_�P�[�X.severity = suggestion -dotnet_naming_rule.�t�B�[���h�ȊO�̃����o�[_should_be_�p�X�J��_�P�[�X.symbols = �t�B�[���h�ȊO�̃����o�[ -dotnet_naming_rule.�t�B�[���h�ȊO�̃����o�[_should_be_�p�X�J��_�P�[�X.style = �p�X�J��_�P�[�X - -# �L���̎d�l - -dotnet_naming_symbols.interface.applicable_kinds = interface -dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.�^.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.�^.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected -dotnet_naming_symbols.�^.required_modifiers = - -dotnet_naming_symbols.�t�B�[���h�ȊO�̃����o�[.applicable_kinds = property, event, method -dotnet_naming_symbols.�t�B�[���h�ȊO�̃����o�[.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected -dotnet_naming_symbols.�t�B�[���h�ȊO�̃����o�[.required_modifiers = -# �����X�^�C�� - -dotnet_naming_style.i_�Ŏn�܂�.required_prefix = I -dotnet_naming_style.i_�Ŏn�܂�.required_suffix = -dotnet_naming_style.i_�Ŏn�܂�.word_separator = -dotnet_naming_style.i_�Ŏn�܂�.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 -dotnet_naming_style.�p�X�J��_�P�[�X.required_prefix = -dotnet_naming_style.�p�X�J��_�P�[�X.required_suffix = -dotnet_naming_style.�p�X�J��_�P�[�X.word_separator = -dotnet_naming_style.�p�X�J��_�P�[�X.capitalization = pascal_case +dotnet_naming_style.camel_case_with__.required_prefix = _ +dotnet_naming_style.camel_case_with__.required_suffix = +dotnet_naming_style.camel_case_with__.word_separator = +dotnet_naming_style.camel_case_with__.capitalization = camel_case -dotnet_naming_style.�p�X�J��_�P�[�X.required_prefix = -dotnet_naming_style.�p�X�J��_�P�[�X.required_suffix = -dotnet_naming_style.�p�X�J��_�P�[�X.word_separator = -dotnet_naming_style.�p�X�J��_�P�[�X.capitalization = pascal_case +[*.{cs,vb}] +dotnet_style_qualification_for_field = true:warning +dotnet_style_qualification_for_property = true:warning +dotnet_style_qualification_for_method = true:warning +dotnet_style_qualification_for_event = true:warning +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +tab_width = 4 +indent_size = 4 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +end_of_line = crlf +insert_final_newline = true +dotnet_code_quality_unused_parameters = all:suggestion +dotnet_style_readonly_field = true:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +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_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_prefer_collection_expression = when_types_exactly_match:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_allow_multiple_blank_lines_experimental = true:silent +dotnet_style_allow_statement_immediately_after_block_experimental = false:warning +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +dotnet_diagnostic.CA1303.severity = suggestion +dotnet_diagnostic.SA1629.severity = none +dotnet_diagnostic.SA1623.severity = none +dotnet_diagnostic.SA1643.severity = none +dotnet_diagnostic.SA1642.severity = none +dotnet_diagnostic.SA1309.severity = none diff --git a/README.md b/README.md index 0eb5fea..f7cc8f3 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,7 @@ 3. `A5:SQL Mk-2` で ER 図の編集 ![](doc/生成直後のER図.png) + +4. `A5:SQL Mk-2` で DDL によるスクリプト生成 + + ![](doc/スクリプト生成.png) diff --git a/src/Disposable.cs b/src/Disposable.cs index 8fed957..611a87a 100644 --- a/src/Disposable.cs +++ b/src/Disposable.cs @@ -31,7 +31,7 @@ public static class Disposable /// /// 何もしない既定の Dispose 可能なインスタンスを表します。 /// - private class NopDisposable : IDisposable + private sealed class NopDisposable : IDisposable { /// public void Dispose() @@ -43,7 +43,7 @@ public void Dispose() /// /// 匿名の インターフェイスの実装を表します。 /// - private class AnonymousDisposable : IDisposable + private sealed class AnonymousDisposable : IDisposable { /// が呼ばれた時の処理を行うメソッドのデリゲートを表します。 private volatile Action? _dispose; diff --git a/src/ExcelToA5er.csproj b/src/ExcelToA5er.csproj index 0ee020f..80d0e55 100644 --- a/src/ExcelToA5er.csproj +++ b/src/ExcelToA5er.csproj @@ -11,9 +11,11 @@ © MareMare A5:SQL Mk-2 で出力されたテーブル定義書からER図(.a5er)へ変換するツールです。 MareMare - 2.0.0 - 2.0.0.0 - 2.0.0.0 + 2.0.1 + 2.0.1.0 + 2.0.1.0 + True + latest-all @@ -25,11 +27,10 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -37,17 +38,17 @@ - + True True - A5erRuntimeTextTemplate.tt + A5ErRuntimeTextTemplate.tt - + TextTemplatingFilePreprocessor - A5erRuntimeTextTemplate.cs + A5ErRuntimeTextTemplate.cs diff --git a/src/MainForm.cs b/src/MainForm.cs index 45c4aa9..88fbafc 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -6,7 +6,7 @@ // -------------------------------------------------------------------------------------------------------------------- using ExcelToA5er.Generators; -using ExcelToA5er.Metadatas; +using ExcelToA5er.Metadata; using ExcelToA5er.Progress; using ExcelToA5er.Templates; @@ -18,7 +18,7 @@ namespace ExcelToA5er; public partial class MainForm : Form { /// 非同期操作の実行時間としての最低時間を表します。 - private static readonly TimeSpan DelayTimeSpan = TimeSpan.FromSeconds(2); + private static readonly TimeSpan _delayTimeSpan = TimeSpan.FromSeconds(2); /// 現在のテーブル定義書情報を表します。 private XlsxInformation? _currentXlsxInfo; @@ -38,8 +38,8 @@ public MainForm() /// リストボックス項目のコレクション。 private static DisplayItem[] ToDisplayItems(XlsxInformation xlsxInfo) { - var items = xlsxInfo?.TableDefinitions?.Select(definition => new DisplayItem(definition)).ToArray(); - return items ?? Array.Empty(); + var items = xlsxInfo.TableDefinitions.Select(definition => new DisplayItem(definition)).ToArray(); + return items ?? []; } /// @@ -49,17 +49,22 @@ private static DisplayItem[] ToDisplayItems(XlsxInformation xlsxInfo) /// テーブル定義情報。 private async Task LoadXlsxAsync(string xlsxFilePath) { - using var progressForm = new ProgressForm { Title = "読み込み" }; - await using var progressScoap = progressForm.UseProgressFormScope(this); - progressScoap.Reporter.ReportStarting("読み込み中です。しばらくお待ちください。"); + using var progressForm = new ProgressForm(); + progressForm.Title = "読み込み"; - var loadTask = XlsxInformation.LoadAsync(xlsxFilePath); - var delayTask = Task.Delay(MainForm.DelayTimeSpan); - await Task.WhenAll(loadTask, delayTask).ConfigureAwait(true); + var progressScope = progressForm.UseProgressFormScope(this); + await using (progressScope.ConfigureAwait(true)) + { + progressScope.Reporter.ReportStarting("読み込み中です。しばらくお待ちください。"); + + var loadTask = XlsxInformation.LoadAsync(xlsxFilePath); + var delayTask = Task.Delay(MainForm._delayTimeSpan); + await Task.WhenAll(loadTask, delayTask).ConfigureAwait(true); - var xlsxInfo = await loadTask.ConfigureAwait(true); - await progressScoap.Reporter.ReportCompletedAsync("読み込みが完了しました。").ConfigureAwait(true); - return xlsxInfo; + var xlsxInfo = await loadTask.ConfigureAwait(true); + await progressScope.Reporter.ReportCompletedAsync("読み込みが完了しました。").ConfigureAwait(true); + return xlsxInfo; + } } /// @@ -70,16 +75,21 @@ private async Task LoadXlsxAsync(string xlsxFilePath) /// 完了を表すタスク。 private async Task SaveA5erAsync(string outputPath, ICollection tableDefinitions) { - using var progressForm = new ProgressForm { Title = "変換" }; - await using var progressScoap = progressForm.UseProgressFormScope(this); - progressScoap.Reporter.ReportStarting("変換中です。しばらくお待ちください。"); + using var progressForm = new ProgressForm(); + progressForm.Title = "変換"; + + var progressScope = progressForm.UseProgressFormScope(this); + await using (progressScope.ConfigureAwait(true)) + { + progressScope.Reporter.ReportStarting("変換中です。しばらくお待ちください。"); - var generateTask = new A5erRuntimeTextTemplate(tableDefinitions).GenerateAsync(outputPath); - var delayTask = Task.Delay(MainForm.DelayTimeSpan); - await Task.WhenAll(generateTask, delayTask).ConfigureAwait(true); + var generateTask = new A5ErRuntimeTextTemplate(tableDefinitions).GenerateAsync(outputPath); + var delayTask = Task.Delay(MainForm._delayTimeSpan); + await Task.WhenAll(generateTask, delayTask).ConfigureAwait(true); - await generateTask.ConfigureAwait(true); - await progressScoap.Reporter.ReportCompletedAsync("変換完了しました。").ConfigureAwait(true); + await generateTask.ConfigureAwait(true); + await progressScope.Reporter.ReportCompletedAsync("変換完了しました。").ConfigureAwait(true); + } } /// @@ -99,7 +109,7 @@ private void MainForm_Load(object sender, EventArgs e) /// イベントソース。 /// イベントデータ。 private void ListBoxTableInfo_SelectedIndexChanged(object sender, EventArgs e) => - this.buttonToConvert.Enabled = this.listBoxTableInfo.SelectedItems.Count > 0 && this._currentXlsxInfo?.A5erFilePath != null; + this.buttonToConvert.Enabled = this.listBoxTableInfo.SelectedItems.Count > 0 && this._currentXlsxInfo?.A5ErFilePath != null; /// /// [参照] ボタンがクリックされたときに発生するイベントのイベントハンドラです。 @@ -108,25 +118,24 @@ private void ListBoxTableInfo_SelectedIndexChanged(object sender, EventArgs e) = /// イベントデータ。 private async void ButtonToBrowseXlsx_Click(object sender, EventArgs e) { - var openFileDialog = new OpenFileDialog - { - Title = "テーブル定義書を選択してください。", - Filter = "テーブル定義書(*.xlsx)|*.xlsx", - RestoreDirectory = true, - CheckFileExists = true, - CheckPathExists = true, - ReadOnlyChecked = true, - ShowReadOnly = true, - }; + using var openFileDialog = new OpenFileDialog(); + openFileDialog.Title = @"テーブル定義書を選択してください。"; + openFileDialog.Filter = @"テーブル定義書(*.xlsx)|*.xlsx"; + openFileDialog.RestoreDirectory = true; + openFileDialog.CheckFileExists = true; + openFileDialog.CheckPathExists = true; + openFileDialog.ReadOnlyChecked = true; + openFileDialog.ShowReadOnly = true; + if (openFileDialog.ShowDialog() == DialogResult.OK) { var xlsxInfo = await this.LoadXlsxAsync(openFileDialog.FileName).ConfigureAwait(true); - var items = MainForm.ToDisplayItems(xlsxInfo); + var items = MainForm.ToDisplayItems(xlsxInfo).Cast().ToArray(); this._currentXlsxInfo = xlsxInfo; this.listBoxTableInfo.Items.Clear(); this.listBoxTableInfo.Items.AddRange(items); this.textBoxXlsxFilePath.Text = Path.GetFileName(xlsxInfo.XlsxFilePath); - this.textBoxOutputFilePath.Text = Path.GetFileName(xlsxInfo.A5erFilePath); + this.textBoxOutputFilePath.Text = Path.GetFileName(xlsxInfo.A5ErFilePath); } } @@ -137,21 +146,21 @@ private async void ButtonToBrowseXlsx_Click(object sender, EventArgs e) /// イベントデータ。 private async void ButtonToConvert_Click(object sender, EventArgs e) { - var a5erFilePath = this._currentXlsxInfo?.A5erFilePath; - if (a5erFilePath == null) + var a5ErFilePath = this._currentXlsxInfo?.A5ErFilePath; + if (a5ErFilePath == null) { return; } var selectedItems = this.listBoxTableInfo.SelectedItems.OfType().ToArray(); var tableDefinitions = selectedItems.Select(item => item.TableInfo).ToArray(); - await this.SaveA5erAsync(a5erFilePath, tableDefinitions).ConfigureAwait(true); + await this.SaveA5erAsync(a5ErFilePath, tableDefinitions).ConfigureAwait(true); } /// /// リストボックス項目を表します。 /// - private class DisplayItem + private sealed class DisplayItem { /// /// クラスの新しいインスタンスを生成します。 @@ -172,6 +181,6 @@ public DisplayItem(TableDefinition tableDefinition) public TableDefinition TableInfo { get; } /// - public override string ToString() => this.TableInfo != null ? $"{this.TableInfo.PhysicalName}: {this.TableInfo.LogicalName}" : "<未設定>"; + public override string ToString() => $"{this.TableInfo.PhysicalName}: {this.TableInfo.LogicalName}"; } } diff --git a/src/Metadatas/ClosedXmlExtensions.cs b/src/Metadata/ClosedXmlExtensions.cs similarity index 77% rename from src/Metadatas/ClosedXmlExtensions.cs rename to src/Metadata/ClosedXmlExtensions.cs index 96b6c7d..2b9a42f 100644 --- a/src/Metadatas/ClosedXmlExtensions.cs +++ b/src/Metadata/ClosedXmlExtensions.cs @@ -7,51 +7,51 @@ using ClosedXML.Excel; -namespace ExcelToA5er.Metadatas; +namespace ExcelToA5er.Metadata; /// -/// Clossed Xml の拡張メソッドを提供します。 +/// Closed Xml の拡張メソッドを提供します。 /// internal static class ClosedXmlExtensions { /// 対象シートを判断する識別子のキーワードを表します。 - private const string TargetSheetKeyword1 = "テーブル情報"; + private const string _targetSheetKeyword1 = "テーブル情報"; /// 対象シートを判断する識別子のキーワードを表します。 - private const string TargetSheetKeyword2 = "エンティティ情報"; + private const string _targetSheetKeyword2 = "エンティティ情報"; /// 対象シートの識別子のセルアドレスを表します。 - private const string CellOfTargetSheetKeyword = "A1"; + private const string _cellOfTargetSheetKeyword = "A1"; /// 論理テーブル名のセルアドレスを表します。 - private const string CellOfTableLogicalName = "C5"; + private const string _cellOfTableLogicalName = "C5"; /// 物理テーブル名のセルアドレスを表します。 - private const string CellOfTablePhysicalName = "C6"; + private const string _cellOfTablePhysicalName = "C6"; /// No.列の先頭セルアドレスを表します。 - private const string CellOfColumnNumberName = "A14"; + private const string _cellOfColumnNumberName = "A14"; /// 論理カラム名の先頭セルアドレスを表します。 - private const string CellOfColumnLogicalName = "B14"; + private const string _cellOfColumnLogicalName = "B14"; /// 物理カラム名の先頭セルアドレスを表します。 - private const string CellOfColumnPhysicalName = "C14"; + private const string _cellOfColumnPhysicalName = "C14"; /// カラムデータ型名の先頭セルアドレスを表します。 - private const string CellOfColumnDataTypeName = "D14"; + private const string _cellOfColumnDataTypeName = "D14"; /// 必須およびPK列の先頭セルアドレスを表します。 - private const string CellOfColumnIsPkOrNotNull = "E14"; + private const string _cellOfColumnIsPkOrNotNull = "E14"; /// カラムコメントの先頭セルアドレスを表します。 - private const string CellOfColumnCommentText = "G14"; + private const string _cellOfColumnCommentText = "G14"; /// PK 列として判定するセル値を表します。 - private const string CellValueOfPK = "PK"; + private const string _cellValueOfPk = "PK"; /// 必須列として判定するセル値を表します。 - private const string CellValueOfNotNull = "Yes"; + private const string _cellValueOfNotNull = "Yes"; /// /// 指定されたワークシートが対象の使徒であるかを取得します。 @@ -62,8 +62,8 @@ public static bool IsTargetSheet(this IXLWorksheet worksheet) { ArgumentNullException.ThrowIfNull(worksheet); - var keyword = worksheet.GetCellStringOrEmpty(CellOfTargetSheetKeyword).Trim().NullIfEmpty(); - return keyword == TargetSheetKeyword1 || keyword == TargetSheetKeyword2; + var keyword = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfTargetSheetKeyword).Trim().NullIfEmpty(); + return keyword is ClosedXmlExtensions._targetSheetKeyword1 or ClosedXmlExtensions._targetSheetKeyword2; } /// @@ -92,8 +92,8 @@ public static IEnumerable LoadTableDefinitions(this IEnumerable { ArgumentNullException.ThrowIfNull(worksheet); - var physicalName = worksheet.GetCellStringOrEmpty(CellOfTablePhysicalName).Trim().NullIfEmpty(); - var logicalName = worksheet.GetCellStringOrEmpty(CellOfTableLogicalName).Trim().NullIfEmpty(); + var physicalName = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfTablePhysicalName).Trim().NullIfEmpty(); + var logicalName = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfTableLogicalName).Trim().NullIfEmpty(); var definition = physicalName != null ? new TableDefinition @@ -140,15 +140,15 @@ private static IEnumerable LoadColumnDefinitions(this IXLWorks /// 継続可能な場合は true。それ以外は false。 private static bool TryLoadColumnDefinition(this IXLWorksheet worksheet, int rowOffset, ref int issuedPkNumber, out ColumnDefinition? definition) { - var numberName = worksheet.GetCellStringOrEmpty(CellOfColumnNumberName, rowOffset).Trim().NullIfEmpty(); - var physicalName = worksheet.GetCellStringOrEmpty(CellOfColumnPhysicalName, rowOffset).Trim().NullIfEmpty(); - var logicalName = worksheet.GetCellStringOrEmpty(CellOfColumnLogicalName, rowOffset).Trim().NullIfEmpty(); - var dataTypeName = worksheet.GetCellStringOrEmpty(CellOfColumnDataTypeName, rowOffset).Trim().NullIfEmpty(); - var commentText = worksheet.GetCellStringOrEmpty(CellOfColumnCommentText, rowOffset).Trim().NullIfEmpty(); + var numberName = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfColumnNumberName, rowOffset).Trim().NullIfEmpty(); + var physicalName = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfColumnPhysicalName, rowOffset).Trim().NullIfEmpty(); + var logicalName = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfColumnLogicalName, rowOffset).Trim().NullIfEmpty(); + var dataTypeName = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfColumnDataTypeName, rowOffset).Trim().NullIfEmpty(); + var commentText = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfColumnCommentText, rowOffset).Trim().NullIfEmpty(); - var isPkOrNotNullText = worksheet.GetCellStringOrEmpty(CellOfColumnIsPkOrNotNull, rowOffset).Trim(); - var isNotNull = isPkOrNotNullText.Contains(CellValueOfNotNull, StringComparison.OrdinalIgnoreCase); - var isPk = isPkOrNotNullText.Contains(CellValueOfPK, StringComparison.OrdinalIgnoreCase); + var isPkOrNotNullText = worksheet.GetCellStringOrEmpty(ClosedXmlExtensions._cellOfColumnIsPkOrNotNull, rowOffset).Trim(); + var isNotNull = isPkOrNotNullText.Contains(ClosedXmlExtensions._cellValueOfNotNull, StringComparison.OrdinalIgnoreCase); + var isPk = isPkOrNotNullText.Contains(ClosedXmlExtensions._cellValueOfPk, StringComparison.OrdinalIgnoreCase); // No.列と物理カラム名ともに有効(空欄以外)な場合に限り、カラム情報として抽出します。 definition = numberName != null && physicalName != null @@ -173,7 +173,7 @@ private static bool TryLoadColumnDefinition(this IXLWorksheet worksheet, int row /// 要素の型。 /// 要素の列挙子。 /// null でない要素の列挙子。 - private static IEnumerable EmptyIfNull(this IEnumerable self) => self ?? Enumerable.Empty(); + private static IEnumerable EmptyIfNull(this IEnumerable? self) => self ?? []; /// /// 空文字列であれば null にします。 diff --git a/src/Metadatas/ColumnDefinition.cs b/src/Metadata/ColumnDefinition.cs similarity index 97% rename from src/Metadatas/ColumnDefinition.cs rename to src/Metadata/ColumnDefinition.cs index a2c0560..02395ba 100644 --- a/src/Metadatas/ColumnDefinition.cs +++ b/src/Metadata/ColumnDefinition.cs @@ -5,12 +5,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ExcelToA5er.Metadatas; +namespace ExcelToA5er.Metadata; /// /// カラム情報を表します。 /// -internal class ColumnDefinition +internal sealed class ColumnDefinition { /// /// 物理カラム名を取得または設定します。 diff --git a/src/Metadatas/TableDefinition.cs b/src/Metadata/TableDefinition.cs similarity index 95% rename from src/Metadatas/TableDefinition.cs rename to src/Metadata/TableDefinition.cs index 34ddcda..49d9db0 100644 --- a/src/Metadatas/TableDefinition.cs +++ b/src/Metadata/TableDefinition.cs @@ -5,12 +5,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ExcelToA5er.Metadatas; +namespace ExcelToA5er.Metadata; /// /// テーブル情報を表します。 /// -internal partial class TableDefinition +internal sealed partial class TableDefinition { /// /// 物理テーブル名を取得します。 diff --git a/src/Metadatas/XlsxInformation.Loader.cs b/src/Metadata/XlsxInformation.Loader.cs similarity index 98% rename from src/Metadatas/XlsxInformation.Loader.cs rename to src/Metadata/XlsxInformation.Loader.cs index 172bd0b..1306a91 100644 --- a/src/Metadatas/XlsxInformation.Loader.cs +++ b/src/Metadata/XlsxInformation.Loader.cs @@ -7,7 +7,7 @@ using ClosedXML.Excel; -namespace ExcelToA5er.Metadatas; +namespace ExcelToA5er.Metadata; /// /// テーブル定義書 Excel ファイル情報を表します。 diff --git a/src/Metadatas/XlsxInformation.cs b/src/Metadata/XlsxInformation.cs similarity index 91% rename from src/Metadatas/XlsxInformation.cs rename to src/Metadata/XlsxInformation.cs index 23a82f3..ae49280 100644 --- a/src/Metadatas/XlsxInformation.cs +++ b/src/Metadata/XlsxInformation.cs @@ -5,12 +5,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ExcelToA5er.Metadatas; +namespace ExcelToA5er.Metadata; /// /// テーブル定義書情報を表します。 /// -internal partial class XlsxInformation +internal sealed partial class XlsxInformation { /// /// XLSX ファイルパスを取得または設定します。 @@ -28,7 +28,7 @@ internal partial class XlsxInformation /// 値を表す 型。 /// A5ER ファイルパス。既定値は null です。 /// - public string A5erFilePath => Path.ChangeExtension(this.XlsxFilePath, ".a5er"); + public string A5ErFilePath => Path.ChangeExtension(this.XlsxFilePath, ".a5er"); /// /// テーブル情報のコレクションを取得または設定します。 diff --git a/src/Program.cs b/src/Program.cs index 837929f..2c98f18 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -19,6 +19,7 @@ internal static class Program internal static void Main() { ApplicationConfiguration.Initialize(); - Application.Run(new MainForm()); + using var mainForm = new MainForm(); + Application.Run(mainForm); } } diff --git a/src/Progress/ProgressForm.cs b/src/Progress/ProgressForm.cs index 82fbfc8..f027ed4 100644 --- a/src/Progress/ProgressForm.cs +++ b/src/Progress/ProgressForm.cs @@ -79,15 +79,18 @@ protected override void OnShown(EventArgs e) private void ProgressForm_Load(object sender, EventArgs e) { this.StartPosition = FormStartPosition.Manual; - this.Location = new Point( - this.Owner.Location.X + ((this.Owner.Width - this.Width) / 2), - this.Owner.Location.Y + ((this.Owner.Height - this.Height) / 2)); + if (this.Owner is not null) + { + this.Location = new Point( + this.Owner.Location.X + ((this.Owner.Width - this.Width) / 2), + this.Owner.Location.Y + ((this.Owner.Height - this.Height) / 2)); + } } /// /// 進捗表示する範囲を表します。 /// - private class ProgressFormScope : IProgressScope + private sealed class ProgressFormScope : IProgressScope { /// を表します。 private readonly ProgressForm _progressForm; diff --git a/src/Progress/ProgressInfo.cs b/src/Progress/ProgressInfo.cs index 75be833..0a50c2b 100644 --- a/src/Progress/ProgressInfo.cs +++ b/src/Progress/ProgressInfo.cs @@ -50,5 +50,5 @@ private ProgressInfo() /// 進捗メッセージ。 /// 進捗率 (0~100%)。 /// 進捗情報。 - public static ProgressInfo New(string message, double percent) => new () { Message = message, Percentage = percent }; + public static ProgressInfo New(string message, double percent) => new() { Message = message, Percentage = percent }; } diff --git a/src/Progress/ProgressReporter.cs b/src/Progress/ProgressReporter.cs index 15d06b5..14fc0fd 100644 --- a/src/Progress/ProgressReporter.cs +++ b/src/Progress/ProgressReporter.cs @@ -10,7 +10,7 @@ namespace ExcelToA5er.Progress; /// /// 進行状況の報告を提供します。 /// -internal class ProgressReporter : Progress, IProgressReporter +internal sealed class ProgressReporter : Progress, IProgressReporter { /// 完了または失敗字のレポートに対するデフォルトのタイムアウト時間を表します。 private readonly TimeSpan _defaultTimeout; diff --git a/src/Templates/A5erRuntimeTextTemplate.cs b/src/Templates/A5ErRuntimeTextTemplate.cs similarity index 93% rename from src/Templates/A5erRuntimeTextTemplate.cs rename to src/Templates/A5ErRuntimeTextTemplate.cs index 7ba3b9c..0fd6001 100644 --- a/src/Templates/A5erRuntimeTextTemplate.cs +++ b/src/Templates/A5ErRuntimeTextTemplate.cs @@ -18,9 +18,9 @@ namespace ExcelToA5er.Templates /// Class to produce the template output /// - #line 1 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 1 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] - public partial class A5erRuntimeTextTemplate : A5erRuntimeTextTemplateBase + public partial class A5ErRuntimeTextTemplate : A5ErRuntimeTextTemplateBase { #line hidden /// @@ -48,118 +48,118 @@ public virtual string TransformText() "); - #line 24 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 24 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" foreach (var tableInfo in this.TableDefinitions) { #line default #line hidden - #line 25 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 25 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" var point = this.ToPoint(tableInfo); #line default #line hidden this.Write("\r\n[Entity]\r\nPName="); - #line 28 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 28 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(tableInfo.PhysicalName)); #line default #line hidden this.Write("\r\nLName="); - #line 29 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 29 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(tableInfo.LogicalName)); #line default #line hidden this.Write("\r\nComment=\r\nTableOption=\r\nPage=MAIN\r\nLeft="); - #line 33 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 33 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(point.X)); #line default #line hidden this.Write("\r\nTop="); - #line 34 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 34 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(point.Y)); #line default #line hidden this.Write("\r\n"); - #line 35 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 35 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" foreach (var columnInfo in tableInfo.ColumnDefinitions) { #line default #line hidden this.Write("Field=\""); - #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(columnInfo.LogicalName)); #line default #line hidden this.Write("\",\""); - #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(columnInfo.PhysicalName)); #line default #line hidden this.Write("\",\""); - #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(columnInfo.SqlDataTypeName)); #line default #line hidden this.Write("\","); - #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(columnInfo.IsNotNullText)); #line default #line hidden this.Write(","); - #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(columnInfo.PkNumberText)); #line default #line hidden this.Write(",\"\",\""); - #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 36 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(columnInfo.Comment)); #line default #line hidden this.Write("\",$FFFFFFFF,\"\"\r\n"); - #line 37 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 37 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" } #line default #line hidden this.Write("Position=\"MAIN\","); - #line 38 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 38 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(point.X)); #line default #line hidden this.Write(","); - #line 38 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 38 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(point.Y)); #line default #line hidden this.Write("\r\n"); - #line 39 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5erRuntimeTextTemplate.tt" + #line 39 "C:\Users\maref\Documents\GitHub\MareMare\ExcelToA5er\src\Templates\A5ErRuntimeTextTemplate.tt" } #line default @@ -175,7 +175,7 @@ public virtual string TransformText() /// Base class for this transformation /// [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] - public class A5erRuntimeTextTemplateBase + public class A5ErRuntimeTextTemplateBase { #region Fields private global::System.Text.StringBuilder generationEnvironmentField; @@ -189,7 +189,7 @@ public class A5erRuntimeTextTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/Templates/A5erRuntimeTextTemplate.partial.cs b/src/Templates/A5ErRuntimeTextTemplate.partial.cs similarity index 86% rename from src/Templates/A5erRuntimeTextTemplate.partial.cs rename to src/Templates/A5ErRuntimeTextTemplate.partial.cs index be34f99..9a6f8ff 100644 --- a/src/Templates/A5erRuntimeTextTemplate.partial.cs +++ b/src/Templates/A5ErRuntimeTextTemplate.partial.cs @@ -1,25 +1,25 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // Copyright © 2021 MareMare All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // // -------------------------------------------------------------------------------------------------------------------- using ExcelToA5er.Generators; -using ExcelToA5er.Metadatas; +using ExcelToA5er.Metadata; namespace ExcelToA5er.Templates; /// /// A5ER ファイルを生成する実行時テンプレートを表します。 /// -public partial class A5erRuntimeTextTemplate : IGenerator +public partial class A5ErRuntimeTextTemplate : IGenerator { /// - /// クラスの新しいインスタンスを生成します。 + /// クラスの新しいインスタンスを生成します。 /// /// テーブル情報のコレクション。 - internal A5erRuntimeTextTemplate(ICollection tableDefinitions) + internal A5ErRuntimeTextTemplate(ICollection tableDefinitions) { ArgumentNullException.ThrowIfNull(tableDefinitions); this.TableDefinitions = tableDefinitions.ToList(); diff --git a/src/Templates/A5erRuntimeTextTemplate.tt b/src/Templates/A5ErRuntimeTextTemplate.tt similarity index 100% rename from src/Templates/A5erRuntimeTextTemplate.tt rename to src/Templates/A5ErRuntimeTextTemplate.tt