diff --git a/.gitignore b/.gitignore index 01cd032..0a94ee7 100644 --- a/.gitignore +++ b/.gitignore @@ -353,4 +353,5 @@ MigrationBackup/ *.db -coverage/ \ No newline at end of file +coverage/ +gh-pages/ \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index 8113edd..fb974ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +### 1.5.2 - 2020-08-xx + * ByteDecoder.Common updated to 0.3.4 + ### 1.5.1 - 2020-07-30 * Added AllowedOutputExtensionsInPackageBuildOutputFolder in the csproj meta diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..4378419 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,9 @@ +############### +# folder # +############### +/**/DROP/ +/**/TEMP/ +/**/packages/ +/**/bin/ +/**/obj/ +_site diff --git a/docs/api/.gitignore b/docs/api/.gitignore new file mode 100644 index 0000000..e8079a3 --- /dev/null +++ b/docs/api/.gitignore @@ -0,0 +1,5 @@ +############### +# temp file # +############### +*.yml +.manifest diff --git a/docs/api/index.md b/docs/api/index.md new file mode 100644 index 0000000..3ddf34e --- /dev/null +++ b/docs/api/index.md @@ -0,0 +1,3 @@ +# ByteDecoder.RoyalLibrary + +Collection of useful LINQ query operators diff --git a/docs/app_logo.svg b/docs/app_logo.svg new file mode 100644 index 0000000..077dfc5 --- /dev/null +++ b/docs/app_logo.svg @@ -0,0 +1,42 @@ + + + + + + Layer 1 + + + + + + + + + + \ No newline at end of file diff --git a/docs/app_racer.svg b/docs/app_racer.svg new file mode 100644 index 0000000..da7c5ec --- /dev/null +++ b/docs/app_racer.svg @@ -0,0 +1,41 @@ + + + + + + + + + \ No newline at end of file diff --git a/docs/articles/intro.md b/docs/articles/intro.md new file mode 100644 index 0000000..206ae70 --- /dev/null +++ b/docs/articles/intro.md @@ -0,0 +1,58 @@ +# Examples and usage + +```csharp +var myArray = new[] { 1, 45, 34, 435 }; + +// Evens and odds +myArray.Evens(); +myArray.Odds(); + +// Sum +myArray.TotalAllEvens(); +myArray.TotalAllOdds(); + +// Times +5.Times(_ => { + var theVar = 13; + Debug.Log($"This is {theVar}"); +}); + +// Sequences, IEnumerable + +// Each +myArray.ForEach(item => Debug.Log($"Using the strength: {item}")); + +string[] shapes = { "circle", "square", "triangle", "octagon" }; + +shapes.ForEach(shape => { + shape = shape.ToUpper(); + Debug.Log(shape); +}); + +// Each with Index +shapes.ForEach((item, index) => { + Debug.Log($"Item: {item.ToUpper()} with index: {index}"); +}); + +// Map +myArray.Map(item => item * 2).Each(item => Debug.Log($"Using the strength doubled: {item}")); + +// Max Element in the sequence +var maxBook = SampleData.Books.MaxElement(book => book.PageCount); +Console.WriteLine($"Max Book Page Count => {maxBook.Title}"); + +// Deferred Execution with StreamReader sequences +using var reader = new StreamReader("books.csv"); + +Data = + from line in reader.Lines() + where !line.StartsWith("#") + let parts = line.Split(',') + select new { Title = parts[1], Publisher = parts[3], Isbn = parts[0] }; + +// Indexes +// 10011001000 +IList source = new List { true, false, false, true, true, false, false, true, false, false, false }; +Data = source.TopIndexes(element => element, 4); + +``` diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml new file mode 100644 index 0000000..ccfbc2a --- /dev/null +++ b/docs/articles/toc.yml @@ -0,0 +1,2 @@ +- name: Examples and Usage + href: intro.md diff --git a/docs/docfx.json b/docs/docfx.json new file mode 100644 index 0000000..affbd02 --- /dev/null +++ b/docs/docfx.json @@ -0,0 +1,50 @@ +{ + "metadata": [ + { + "src": [ + { + "files": ["src/RoyalLibrary/RoyalLibrary.csproj"], + "exclude": ["**/obj/**", "**/bin/**", "_site/**"], + "cwd": ".." + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false + } + ], + "build": { + "content": [ + { + "files": ["api/**.yml", "api/index.md"] + }, + { + "files": ["articles/**.md", "articles/**/toc.yml", "toc.yml", "*.md"] + } + ], + "resource": [ + { + "files": ["images/**", "app_racer.svg", "racer.ico"] + } + ], + "overwrite": [ + { + "files": ["apidoc/**.md"], + "exclude": ["obj/**", "_site/**"] + } + ], + "dest": "_site", + "globalMetadata": { + "_appLogoPath": "./app_racer.svg", + "_appFaviconPath": "racer.ico" + }, + "fileMetadataFiles": [], + "template": ["default"], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..f0e6ee4 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,31 @@ +# Royal Library + +![.NET Core](https://github.com/ByteDecoder/RoyalLibrary/workflows/.NET%20Core/badge.svg?branch=master) +[![Maintainability](https://api.codeclimate.com/v1/badges/7e3f41ebb34cf31f1d82/maintainability)](https://codeclimate.com/github/ByteDecoder/RoyalLibrary/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/7e3f41ebb34cf31f1d82/test_coverage)](https://codeclimate.com/github/ByteDecoder/RoyalLibrary/test_coverage) + +Collection of useful LINQ query operators + +Targeted to .Net Standard 2.0 + +## Installation + +Install the [RoyalLibrary NuGet Package](https://www.nuget.org/packages/ByteDecoder.RoyalLibrary). + +### Package Manager Console + +```powershell +Install-Package ByteDecoder.RoyalLibrary +``` + +### .NET Core CLI + +```bash +dotnet add package ByteDecoder.RoyalLibrary +``` + +## Contributing + +Bug reports and pull requests are welcome on GitHub at . + +Copyright (c) 2020 [Rodrigo Reyes](https://twitter.com/bytedecoder) released under the MIT license diff --git a/docs/racer.ico b/docs/racer.ico new file mode 100644 index 0000000..ab61468 Binary files /dev/null and b/docs/racer.ico differ diff --git a/docs/toc.yml b/docs/toc.yml new file mode 100644 index 0000000..59f8010 --- /dev/null +++ b/docs/toc.yml @@ -0,0 +1,5 @@ +- name: Articles + href: articles/ +- name: Api Documentation + href: api/ + homepage: api/index.md diff --git a/media/racer.ico b/media/racer.ico new file mode 100644 index 0000000..ab61468 Binary files /dev/null and b/media/racer.ico differ diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 0000000..55fd007 --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,250 @@ +# Schema: http://EditorConfig.org +# Docs: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference + +# top-most EditorConfig file +root = true + +# Don't use tabs for indentation. +[*] +indent_style = space +trim_trailing_whitespace = true + +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 +insert_final_newline = true +charset = utf-8-bom + +# 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,xml,stylecop}] +indent_size = 2 + +# JSON files +[*.{json,json5}] +indent_size = 2 + +# YAML Files +[*.{yml,yaml}] +indent_size = 2 + +# Shell scripts +[*.sh] +end_of_line = lf + +[*.{cmd,bat}] +end_of_line = crlf + +# Web Files +[*.{htm,html,js,ts,css,scss,less}] +indent_size = 2 +insert_final_newline = true + +## Language conventions +# Dotnet code style settings: +[*.{cs,csx,cake,vb}] +# Avoid "this." and "Me." if not necessary +dotnet_style_qualification_for_event = false : warning +dotnet_style_qualification_for_field = false : warning +dotnet_style_qualification_for_method = false : warning +dotnet_style_qualification_for_property = false : warning + +# Use language keywords instead of framework type names for type references +dotnet_style_predefined_type_for_locals_parameters_members = true : warning +dotnet_style_predefined_type_for_member_access = true : warning + +# Expression-level preferences +dotnet_style_coalesce_expression = true : suggestion +dotnet_style_collection_initializer = true : suggestion +dotnet_style_explicit_tuple_names = true : warning +dotnet_style_null_propagation = true : suggestion +dotnet_style_object_initializer = true : suggestion +dotnet_style_require_accessibility_modifiers = always : warning + +dotnet_style_prefer_is_null_check_over_reference_equality_method = true : warning +dotnet_style_readonly_field = true : warning +dotnet_style_prefer_auto_properties = true : suggestion +dotnet_style_prefer_inferred_tuple_names = true : suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true : suggestion + +# CSharp code style settings: +[*.cs] +# Prefer "var" everywhere (Implicit and explicit types) +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : warning + +# Expression-Bodied members +csharp_style_expression_bodied_accessors = true : suggestion +csharp_style_expression_bodied_indexers = true : suggestion +csharp_style_expression_bodied_operators = true : suggestion +csharp_style_expression_bodied_properties = true : suggestion +# Explicitly disabled due to difference in coding style between source and tests +#csharp_style_expression_bodied_constructors = true : warning +#csharp_style_expression_bodied_methods = true : warning + +# Pattern matching +csharp_style_pattern_matching_over_as_with_null_check = true : suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion + +# Inlined variable declarations +csharp_style_inlined_variable_declaration = true : suggestion + +# Expression-level preferences +csharp_prefer_inferred_anonymous_type_member_names = true : warning +csharp_prefer_inferred_tuple_names = true : warning +csharp_prefer_simple_default_expression = true : warning +csharp_preferred_modifier_order = public,private,protected,internal,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_style_deconstructed_variable_declaration = true : warning +csharp_style_pattern_local_over_anonymous_function = true : warning + +# Null-checking preference +csharp_style_conditional_delegate_call = true : warning +csharp_style_throw_expression = true : warning + +# Code block preferences +#csharp_prefer_braces = true : suggestion # Disabled because it doesn't support no braces for control flow keywords (return, break, throw) + +## Formatting conventions +# Dotnet formatting settings: +[*.{cs,vb}] +# Organize usings +dotnet_sort_system_directives_first = true + +# CSharp formatting settings: +[*.cs] +# Newline options +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 + +# Identation options +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +# Spacing options +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false + +# Wrapping options +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +## Naming conventions +[*.{cs,vb}] + +# Non-private static fields are PascalCase +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields +dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style + +dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected internal, private protected +dotnet_naming_symbols.non_private_static_fields.required_modifiers = static + +dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case + +# Constants are PascalCase +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants +dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style + +dotnet_naming_symbols.constants.applicable_kinds = field, local +dotnet_naming_symbols.constants.required_modifiers = const + +dotnet_naming_style.constant_style.capitalization = pascal_case + +# Static fields are camelCase and start with s_ +dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields +dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style + +dotnet_naming_symbols.static_fields.applicable_kinds = field +dotnet_naming_symbols.static_fields.required_modifiers = static + +dotnet_naming_style.static_field_style.capitalization = camel_case +dotnet_naming_style.static_field_style.required_prefix = s_ + +# Instance fields are camelCase and start with _ +dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields +dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style + +dotnet_naming_symbols.instance_fields.applicable_kinds = field + +dotnet_naming_style.instance_field_style.capitalization = camel_case +dotnet_naming_style.instance_field_style.required_prefix = _ + +# Locals and parameters are camelCase +dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion +dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters +dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style + +dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local +dotnet_naming_style.camel_case_style.capitalization = camel_case + +# Local functions are PascalCase +dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function +dotnet_naming_style.local_function_style.capitalization = pascal_case + +# Type Parameters +dotnet_naming_style.type_parameter_style.capitalization = pascal_case +dotnet_naming_style.type_parameter_style.required_prefix = T + +dotnet_naming_rule.type_parameter_naming.symbols = type_parameter_symbol +dotnet_naming_rule.type_parameter_naming.style = type_parameter_style +dotnet_naming_rule.type_parameter_naming.severity = warning +dotnet_naming_symbols.type_parameter_symbol.applicable_kinds = type_parameter +dotnet_naming_symbols.type_parameter_symbol.applicable_accessibilities = * + +# By default, name items with PascalCase +dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members +dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.all_members.applicable_kinds = * + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +## Analyzers +# IDE0002: Name can be simplified +dotnet_diagnostic.IDE0002.severity = suggestion + +# IDE0005: Remove unnecessary imports +dotnet_diagnostic.IDE0005.severity = suggestion + +# IDE1006: Naming rule violation +dotnet_diagnostic.IDE1006.severity = suggestion + +# MA0006: use String.Equals +dotnet_diagnostic.MA0006.severity = none + +# Meziantou Analyzer +MA0051.maximum_statements_per_method = 40 +MA0051.skip_local_functions = false +MA0051.maximum_lines_per_method = 60 +MA0053.public_class_should_be_sealed = true \ No newline at end of file diff --git a/src/RoyalLibrary/ConditionalIndexExtensions.cs b/src/RoyalLibrary/ConditionalIndexExtensions.cs index 592bcf7..fb754ad 100644 --- a/src/RoyalLibrary/ConditionalIndexExtensions.cs +++ b/src/RoyalLibrary/ConditionalIndexExtensions.cs @@ -6,7 +6,7 @@ namespace ByteDecoder.RoyalLibrary { /// - /// + /// /// public static class ConditionalIndexExtensions { diff --git a/src/RoyalLibrary/RoyalLibrary.csproj b/src/RoyalLibrary/RoyalLibrary.csproj index 65ca446..2cb09b3 100644 --- a/src/RoyalLibrary/RoyalLibrary.csproj +++ b/src/RoyalLibrary/RoyalLibrary.csproj @@ -17,7 +17,7 @@ icon.png true ByteDecoder.RoyalLibrary - https://github.com/ByteDecoder/RoyalLibrary + https://bytedecoder.me/RoyalLibrary Collection of useful LINQ query operators $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb @@ -29,7 +29,7 @@ - + diff --git a/src/release-docfx.sh b/src/release-docfx.sh new file mode 100755 index 0000000..8ecb639 --- /dev/null +++ b/src/release-docfx.sh @@ -0,0 +1,29 @@ +#!/bin/sh +set -e + +export VSINSTALLDIR="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" +export VisualStudioVersion="16.0" + +docfx ../docs/docfx.json + +SOURCE_DIR=$PWD/../docs +TEMP_REPO_DIR=$PWD/../gh-pages + +echo "Removing temporary doc directory $TEMP_REPO_DIR" +rm -rf $TEMP_REPO_DIR +mkdir $TEMP_REPO_DIR + +echo "Cloning the repo with the gh-pages branch" +git clone git@github.com:ByteDecoder/RoyalLibrary.git --branch gh-pages $TEMP_REPO_DIR + +echo "Clear repo directory" +cd $TEMP_REPO_DIR +git rm -r * + +echo "Copy documentation into the repo" +cp -r $SOURCE_DIR/../docs/_site/* . + +echo "Push the new docs to the remote branch" +git add . -A +git commit -m "Update generated documentation" +git push origin gh-pages \ No newline at end of file diff --git a/src/run-testsuite.sh b/src/run-testsuite.sh new file mode 100755 index 0000000..6bc33bd --- /dev/null +++ b/src/run-testsuite.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +clear + +rm -r ../coverage/* + +dotnet test RoyalLibrary.sln --logger:trx \ + --results-directory ../../coverage \ + /p:CollectCoverage=true \ + /p:CoverletOutput=../../coverage/ \ + /p:CoverletOutputFormat=\"lcov,json\" \ + /p:MergeWith=../../coverage/coverage.json + +echo "Preparing lcov.info for Coverage Gutters" +rm ../coverage/lcov.info +mv ../coverage/coverage.info ../coverage/lcov.info + +echo Preparing Test Report with reportgenerator +reportgenerator "-reports:../coverage/lcov.info" "-reporttypes:HTMLInline;Badges" "-targetdir:../coverage/report" + +echo "We are Legion..." \ No newline at end of file