Skip to content

Commit

Permalink
Merge pull request #191 from SceneGate/feature/new-converter-api
Browse files Browse the repository at this point in the history
✨🔥 Implement new converter API
  • Loading branch information
pleonex committed Nov 18, 2023
2 parents d7dc63a + 61d0499 commit c616cc0
Show file tree
Hide file tree
Showing 47 changed files with 2,203 additions and 1,780 deletions.
133 changes: 107 additions & 26 deletions src/.editorconfig → .editorconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
# Top-level config file
root = true

# All files
[*]
indent_style = space

[*.md]
charset = utf-8
insert_final_newline = true
end_of_line = unset # Leave it to git
indent_style = space
indent_size = 2
max_line_length = 80

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# Generic C# files
[*.cs]
[*.{cs,vb}]

## Generic options
charset = utf-8
charset = utf-8-bom
indent_size = 4
indent_style = space
tab_width = 8
trim_trailing_whitespace = true
end_of_line = lf
end_of_line = unset # Leave it to git
insert_final_newline = true

## .NET style rules
### Organize using
### Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true
file_header_template = unset # too long to set here
Expand All @@ -31,6 +51,7 @@ dotnet_style_predefined_type_for_member_access = true:warning

### Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
dotnet_diagnostic.SA1400.severity = suggestion # it doesn't follow the above value
dotnet_style_readonly_field = true:warning

### Parentheses preferences
Expand All @@ -45,16 +66,16 @@ dotnet_style_collection_initializer = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_return = true:warning
dotnet_style_prefer_compound_assignment = true:warning
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:warning
dotnet_style_prefer_simplified_boolean_expressions = true:warning
dotnet_style_operator_placement_when_wrapping = end_of_line

### Null-checking preferences
dotnet_style_coalesce_expression = true:warning
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning

Expand All @@ -67,23 +88,25 @@ dotnet_remove_unnecessary_suppression_exclusions = none
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion
dotnet_diagnostic.IDE0008.severity = suggestion # Doesn't follow above values

### Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_methods = false
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = when_on_single_line:warning
csharp_style_expression_bodied_indexers = when_on_single_line:warning
csharp_style_expression_bodied_accessors = when_on_single_line:warning
csharp_style_expression_bodied_lambdas = when_on_single_line:warning
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
csharp_style_expression_bodied_lambdas = when_on_single_line:suggestion
csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion

### Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_prefer_switch_expression = true:warning
csharp_style_prefer_pattern_matching = true:warning
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_not_pattern = true:warning
csharp_style_prefer_null_check_over_type_check = true:suggestion

### Expression-level preferences
csharp_style_inlined_variable_declaration = true:warning
Expand All @@ -94,26 +117,37 @@ csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:warning
csharp_style_unused_value_expression_statement_preference = discard_variable:warning
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
csharp_style_prefer_method_group_conversion = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion

### Null-checking preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning

### Code-block preferences
csharp_prefer_braces = when_multiline:error
csharp_prefer_braces = when_multiline:warning
dotnet_diagnostic.SA1503.severity = suggestion # Braces can be omitted (guards can)
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion

### 'using' directive preferences
csharp_using_directive_placement = inside_namespace:warning
dotnet_diagnostic.SA1200.severity = warning # Doesn't follow above value

### Modifier preferences
csharp_prefer_static_local_function = true:warning
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning

### New C# features
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion

## C# formatting rules
### New line preferences
csharp_new_line_before_open_brace = local_functions,methods,types
csharp_new_line_before_open_brace = methods,types
csharp_new_line_before_else = false
csharp_new_line_before_catch = false
csharp_new_line_before_finally = false
Expand All @@ -128,6 +162,7 @@ csharp_indent_labels = one_less_than_current
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false
csharp_style_namespace_declarations = file_scoped

### Spacing preferences
csharp_space_after_cast = false
Expand Down Expand Up @@ -157,28 +192,73 @@ csharp_space_between_square_brackets = false
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true

### Top level statement
csharp_style_prefer_top_level_statements = true:silent

## Naming styles rules
dotnet_style_namespace_match_folder = true:warning
dotnet_diagnostic.IDE1006.severity = warning

dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
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_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_rule.types_should_be_pascal_case.severity = warning
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = 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

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
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 =

## Code analyzers
### .NET SDK
dotnet_diagnostic.CA1303.severity = none # We don't translate exception and log messages from English
dotnet_diagnostic.IDE0058.severity = suggestion # Expression value is never used
dotnet_diagnostic.SA1025.severity = none # Allow spaces in comments to structure info
dotnet_diagnostic.IDE0045.severity = suggestion # Simplify ifs
dotnet_diagnostic.IDE0046.severity = suggestion # Simplify ifs

### StyleCop
dotnet_diagnostic.SA1000.severity = none # false positive, space before parentheses in new()
dotnet_diagnostic.SA1009.severity = none # false positive with ()! for null checking
dotnet_diagnostic.SA1011.severity = none # False positive due to nullables
dotnet_diagnostic.SA1101.severity = none # Do not force to prefix local calls with 'this'
dotnet_diagnostic.SA1400.severity = suggestion # Access modifier may be omitted
dotnet_diagnostic.SA1313.severity = none # Pascal naming broken with records.
dotnet_diagnostic.SA1204.severity = suggestion # Static methods should be before non-static
dotnet_diagnostic.SA1500.severity = none # Allow inline braces
dotnet_diagnostic.SA1503.severity = suggestion # Braces can be omitted (guards can)
dotnet_diagnostic.SA1516.severity = none # Multiple blank lines - broken with top-level statements
dotnet_diagnostic.SA1633.severity = none # No XML-format header in source files

### SonarAnalyzer
dotnet_diagnostic.S1133.severity = suggestion # Remove deprecated code -.-' I know, some day
dotnet_diagnostic.S1135.severity = suggestion # It's almost inevitable to have TODO but add bug ID
dotnet_diagnostic.S1133.severity = suggestion # Remove obsoletes

# Special rules for test and example projects
[{*Tests/**,*Examples/**}]
[{src/*Tests/**,src/*Examples/**}]
dotnet_diagnostic.CS1591.severity = none # Disable documentation
dotnet_diagnostic.CS0618.severity = suggestion # Obsolete methods
dotnet_diagnostic.CA1001.severity = none # No need to implement IDisposable in test classes with cleanup.
dotnet_diagnostic.CA1034.severity = none # Public types in test classes for testing implementations
dotnet_diagnostic.CA1040.severity = none # Empty interfaces for testing
Expand All @@ -187,11 +267,15 @@ dotnet_diagnostic.CA1305.severity = none # No culture method for quick test code
dotnet_diagnostic.CA1307.severity = none # No culture method for quick test code
dotnet_diagnostic.SA0001.severity = none # Disable documentation
dotnet_diagnostic.SA1600.severity = none # Disable documentation
dotnet_diagnostic.SA1601.severity = none # Disable documentation
dotnet_diagnostic.SA1201.severity = none # Allow enums inside classes
dotnet_diagnostic.S1144.severity = none # Remove unused setter
dotnet_diagnostic.S2094.severity = none # Remove empty class
dotnet_diagnostic.S2699.severity = none # Assert may be in helper methods
dotnet_diagnostic.S3966.severity = none # Dispose twice to test implementation
dotnet_code_quality_unused_parameters = all:none # Some test methods may not use all the source args

[*Examples/**]
[src/*Examples/**]
dotnet_diagnostic.SA1123.severity = none # Allow regions to insert code snippets in markdown
dotnet_diagnostic.SA1124.severity = none # Allow regions to insert code snippets in markdown
dotnet_diagnostic.S1481.severity = none # Allow unused variables
Expand All @@ -200,7 +284,4 @@ dotnet_diagnostic.IDE0060.severity = none # Allow unused variables
dotnet_diagnostic.RCS1163.severity = none # Allow unused variables
dotnet_diagnostic.SA1515.severity = none # Allow comments after #region
dotnet_diagnostic.SA1512.severity = none # Allow spaces after comments

# TODO: Reconsider after bumping versions, seems to be buggy
dotnet_diagnostic.SA1313.severity = suggestion # Seems to be a bug with records
dotnet_diagnostic.SA1000.severity = none # Space before parentheses in new()
dotnet_diagnostic.S4487.severity = none # Remove unread variable
4 changes: 4 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
overrides:
- files: "*.md"
options:
proseWrap: always
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Yarhl, A format ResearcH Library [![awesomeness](https://img.shields.io/badge/SceneGate-awesome%20%F0%9F%95%B6-blue?logo=csharp)](https://github.com/SceneGate)

![Yarhl Logo](https://raw.githubusercontent.com/SceneGate/Yarhl/develop/docs/images/logo.png)
![Yarhl Logo](./docs/images/logo-large.png)

<!-- markdownlint-disable MD033 -->
<p align="center">
Expand Down
1 change: 1 addition & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Task("Define-Project")
info.AddLibraryProjects("Yarhl");
info.AddLibraryProjects("Yarhl.Media.Text");
info.AddLibraryProjects("Yarhl.Plugins");
info.AddTestProjects("Yarhl.UnitTests");
info.AddTestProjects("Yarhl.IntegrationTests");
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/core/virtual-file-system/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ parameterless constructor (default case) you can use the short API

If it takes parameters or the instance needs to be created in a different way
(e.g. factory), pass the converter object via
[`TransformWith(converter)`](<xref:Yarhl.FileSystem.Node.TransformWith``2(Yarhl.FileFormat.IConverter{``0,``1})>).
[`TransformWith(converter)`](<xref:Yarhl.FileSystem.Node.TransformWith(Yarhl.FileFormat.IConverter)>).

[!code-csharp[transform](./../../../../src/Yarhl.Examples/FileSystem/NodeExamples.cs?name=Transform)]

Expand Down
1 change: 0 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All"/>
<PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="All"/>
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="All"/>
</ItemGroup>
</Project>
45 changes: 20 additions & 25 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<Project>
<!-- Centralize dependency management -->
<ItemGroup>
<PackageVersion Include="System.Composition" Version="6.0.0" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
<PackageVersion Include="System.Buffers" Version="4.5.1" />

<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.2.0"/>
<PackageVersion Include="coverlet.collector" Version="3.1.2" />
<PackageVersion Include="Moq" Version="4.18.2" />

<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />

<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />

<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="8.43.0.51858" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.1.1" />
</ItemGroup>
</Project>
<!-- Centralize dependency management -->
<ItemGroup>
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="System.Composition" Version="6.0.0" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
<PackageVersion Include="System.Buffers" Version="4.5.1" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.12.0.78982" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/Yarhl.IntegrationTests/PluginDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Yarhl.IntegrationTests
using System.IO;
using System.Linq;
using NUnit.Framework;
using Yarhl.Plugins;

[TestFixture]
public class PluginDiscovery
Expand Down
6 changes: 4 additions & 2 deletions src/Yarhl.IntegrationTests/Yarhl.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Yarhl\Yarhl.csproj" />

<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="coverlet.collector" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Yarhl.Plugins\Yarhl.Plugins.csproj" />
</ItemGroup>

</Project>

0 comments on commit c616cc0

Please sign in to comment.