diff --git a/.editorconfig b/.editorconfig
index 51b994c..b8193cc 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,121 +1,123 @@
-root=true
+root = true
+["*"]
+charset = "utf-8"
+csharp_new_line_before_members_in_object_initializers = false
+csharp_preferred_modifier_order = "public, override, protected, internal, file, new, virtual, abstract, private, sealed, readonly, static, extern, unsafe, volatile, async, required:suggestion"
+csharp_preserve_single_line_blocks = true
+csharp_preserve_single_line_statements = false
+csharp_space_after_cast = false
+csharp_style_var_elsewhere = "false:hint"
+csharp_style_var_for_built_in_types = "false:hint"
+csharp_style_var_when_type_is_apparent = "true:hint"
+curly_bracket_next_line = true
+dotnet_style_predefined_type_for_locals_parameters_members = "true:hint"
+dotnet_style_predefined_type_for_member_access = "true:hint"
+dotnet_style_qualification_for_event = "true:hint"
+dotnet_style_qualification_for_field = "true:hint"
+dotnet_style_qualification_for_method = "true:hint"
+dotnet_style_qualification_for_property = "true:hint"
+dotnet_style_require_accessibility_modifiers = "for_non_interface_members:hint"
+end_of_line = "lf"
+indent_brace_style = "K&R"
+indent_size = 4
+indent_style = "space"
+insert_final_newline = true
+max_line_length = 80
+resharper_alignment_tab_fill_style = "optimal_fill"
+resharper_apply_on_completion = true
+resharper_blank_lines_after_control_transfer_statements = 1
+resharper_blank_lines_around_single_line_auto_property = 1
+resharper_blank_lines_around_single_line_property = 1
+resharper_blank_lines_before_block_statements = 1
+resharper_blank_lines_before_control_transfer_statements = 1
+resharper_blank_lines_before_single_line_comment = 1
+resharper_blank_lines_between_using_groups = 1
+resharper_braces_for_for = "required"
+resharper_braces_for_foreach = "required"
+resharper_braces_for_ifelse = "required"
+resharper_braces_for_while = "required"
+resharper_can_use_global_alias = false
+resharper_check_namespace_highlighting = "none"
+resharper_convert_to_auto_property_highlighting = "none"
+resharper_csharp_blank_lines_around_single_line_field = 1
+resharper_csharp_blank_lines_around_single_line_invocable = 1
+resharper_csharp_empty_block_style = "together_same_line"
+resharper_csharp_indent_style = "tab"
+resharper_csharp_insert_final_newline = true
+resharper_csharp_keep_blank_lines_in_code = 1
+resharper_csharp_keep_blank_lines_in_declarations = 1
+resharper_csharp_max_line_length = 100
+resharper_csharp_new_line_before_while = true
+resharper_csharp_use_indent_invocation_rpar = true
+resharper_csharp_wrap_extends_list_style = "chop_if_long"
+resharper_csharp_wrap_parameters_style = "chop_if_long"
+resharper_css_insert_final_newline = false
+resharper_enforce_line_ending_style = true
+resharper_html_insert_final_newline = false
+resharper_indent_nested_fixed_stmt = true
+resharper_js_indent_style = "spaces"
+resharper_js_insert_final_newline = true
+resharper_js_keep_blank_lines_in_code = 1
+resharper_js_stick_comment = false
+resharper_js_use_indent_from_vs = false
+resharper_js_wrap_before_binary_opsign = true
+resharper_js_wrap_chained_method_calls = "chop_if_long"
+resharper_keep_blank_lines_between_declarations = 1
+resharper_localizable_element_highlighting = "none"
+resharper_min_blank_lines_after_imports = 1
+resharper_place_attribute_on_same_line = false
+resharper_place_constructor_initializer_on_same_line = false
+resharper_place_expr_property_on_single_line = true
+resharper_place_simple_initializer_on_single_line = false
+resharper_place_type_constraints_on_same_line = false
+resharper_protobuf_insert_final_newline = false
+resharper_qualified_using_at_nested_scope = true
+resharper_redundant_comma_in_attribute_list_highlighting = "none"
+resharper_redundant_comma_in_enum_declaration_highlighting = "none"
+resharper_redundant_comma_in_initializer_highlighting = "none"
+resharper_resx_insert_final_newline = false
+resharper_space_within_single_line_array_initializer_braces = true
+resharper_string_compare_to_is_culture_specific_highlighting = "none"
+resharper_string_index_of_is_culture_specific_1_highlighting = "none"
+resharper_use_indents_from_main_language_in_file = false
+resharper_use_null_propagation_highlighting = "none"
+resharper_use_object_or_collection_initializer_highlighting = "hint"
+resharper_use_string_interpolation_highlighting = "hint"
+resharper_vb_insert_final_newline = false
+resharper_wrap_after_declaration_lpar = true
+resharper_wrap_after_invocation_lpar = true
+resharper_wrap_before_extends_colon = true
+resharper_wrap_before_first_type_parameter_constraint = true
+resharper_wrap_before_type_parameter_langle = true
+resharper_xml_insert_final_newline = false
+resharper_xmldoc_indent_child_elements = "ZeroIndent"
+resharper_xmldoc_indent_text = "ZeroIndent"
+resharper_xmldoc_insert_final_newline = false
+tab_width = 4
+trim_trailing_whitespace = true
-[*]
-charset=utf-8
-csharp_new_line_before_members_in_object_initializers=false
-csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
-csharp_preserve_single_line_blocks=true
-csharp_preserve_single_line_statements=false
-csharp_space_after_cast=false
-csharp_style_var_elsewhere=false:hint
-csharp_style_var_for_built_in_types=false:hint
-csharp_style_var_when_type_is_apparent=true:hint
-curly_bracket_next_line=true
-dotnet_style_predefined_type_for_locals_parameters_members=true:hint
-dotnet_style_predefined_type_for_member_access=true:hint
-dotnet_style_qualification_for_event=true:hint
-dotnet_style_qualification_for_field=true:hint
-dotnet_style_qualification_for_method=true:hint
-dotnet_style_qualification_for_property=true:hint
-dotnet_style_require_accessibility_modifiers=for_non_interface_members:hint
-end_of_line=lf
-indent_brace_style=K&R
-indent_size=4
-indent_style=space
-insert_final_newline=true
-max_line_length=80
-resharper_alignment_tab_fill_style=optimal_fill
-resharper_apply_on_completion=true
-resharper_blank_lines_after_control_transfer_statements=1
-resharper_blank_lines_around_single_line_auto_property=1
-resharper_blank_lines_around_single_line_property=1
-resharper_blank_lines_before_single_line_comment=1
-resharper_blank_lines_between_using_groups=1
-resharper_braces_for_for=required
-resharper_braces_for_foreach=required
-resharper_braces_for_ifelse=required
-resharper_braces_for_while=required
-resharper_can_use_global_alias=false
-resharper_check_namespace_highlighting=none
-resharper_convert_to_auto_property_highlighting=none
-resharper_csharp_blank_lines_around_single_line_field=1
-resharper_csharp_blank_lines_around_single_line_invocable=1
-resharper_csharp_indent_style=tab
-resharper_csharp_insert_final_newline=true
-resharper_csharp_keep_blank_lines_in_code=1
-resharper_csharp_keep_blank_lines_in_declarations=1
-resharper_csharp_new_line_before_while=true
-resharper_csharp_use_indent_from_vs=false
-resharper_csharp_wrap_arguments_style=chop_if_long
-resharper_csharp_wrap_extends_list_style=chop_if_long
-resharper_csharp_wrap_parameters_style=chop_if_long
-resharper_css_insert_final_newline=false
-resharper_enforce_line_ending_style=true
-resharper_html_insert_final_newline=false
-resharper_indent_nested_fixed_stmt=true
-resharper_js_indent_style=tab
-resharper_js_insert_final_newline=true
-resharper_js_keep_blank_lines_in_code=1
-resharper_js_stick_comment=false
-resharper_js_use_indent_from_vs=false
-resharper_js_wrap_before_binary_opsign=true
-resharper_js_wrap_chained_method_calls=chop_if_long
-resharper_keep_blank_lines_between_declarations=1
-resharper_localizable_element_highlighting=none
-resharper_min_blank_lines_after_imports=1
-resharper_place_attribute_on_same_line=false
-resharper_place_constructor_initializer_on_same_line=false
-resharper_place_type_constraints_on_same_line=false
-resharper_protobuf_insert_final_newline=false
-resharper_qualified_using_at_nested_scope=true
-resharper_redundant_comma_in_attribute_list_highlighting=none
-resharper_redundant_comma_in_enum_declaration_highlighting=none
-resharper_redundant_comma_in_initializer_highlighting=none
-resharper_resx_insert_final_newline=false
-resharper_space_within_single_line_array_initializer_braces=true
-resharper_string_compare_to_is_culture_specific_highlighting=none
-resharper_string_index_of_is_culture_specific_1_highlighting=none
-resharper_use_indents_from_main_language_in_file=false
-resharper_use_null_propagation_highlighting=none
-resharper_use_object_or_collection_initializer_highlighting=hint
-resharper_use_string_interpolation_highlighting=hint
-resharper_vb_insert_final_newline=false
-resharper_wrap_after_declaration_lpar=true
-resharper_wrap_after_invocation_lpar=true
-resharper_wrap_before_extends_colon=true
-resharper_wrap_before_first_type_parameter_constraint=true
-resharper_wrap_before_type_parameter_langle=true
-resharper_xml_insert_final_newline=false
-resharper_xmldoc_indent_child_elements=ZeroIndent
-resharper_xmldoc_indent_text=ZeroIndent
-resharper_xmldoc_insert_final_newline=false
-tab_width=4
-trim_trailing_whitespace=true
+["*.cs"]
+indent_size = 4
+indent_style = "space"
+tab_width = 4
-[*.md]
-max_line_length=off
-trim_trailing_whitespace=false
+["*.md"]
+max_line_length = "off"
-[*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
-indent_size=2
-indent_style=space
-tab_width=2
+["*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]"]
+indent_size = 2
+indent_style = "space"
+tab_width = 2
-[*.{diff,patch}]
-end_of_line=unset
-indent_size=unset
-insert_final_newline=unset
-trim_trailing_whitespace=unset
+["package.json"]
+indent_size = 2
+indent_style = "space"
+tab_width = 2
-[package.json]
-indent_size=2
-indent_style=space
-tab_width=2
-
-[{LICENSES/**,LICENSE}]
-charset=unset
-end_of_line=unset
-indent_size=unset
-indent_style=unset
-insert_final_newline=unset
-trim_trailing_whitespace=unset
+["{LICENSES/**,LICENSE}"]
+charset = "unset"
+end_of_line = "unset"
+indent_size = "unset"
+indent_style = "unset"
+insert_final_newline = "unset"
+trim_trailing_whitespace = "unset"
diff --git a/.gitignore b/.gitignore
index 9420dd7..fd5caa0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ TestResults/
tests/artifacts/
# nixago: ignore-linked-files
+/.prettierrc.json
/lefthook.yml
/.conform.yaml
-/treefmt.toml
+/treefmt.toml
\ No newline at end of file
diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md
index 5aa66ee..88c4db8 100644
--- a/CODE-OF-CONDUCT.md
+++ b/CODE-OF-CONDUCT.md
@@ -17,24 +17,24 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:
-- Demonstrating empathy and kindness toward other people
-- Being respectful of differing opinions, viewpoints, and experiences
-- Giving and gracefully accepting constructive feedback
-- Accepting responsibility and apologizing to those affected by our mistakes,
- and learning from the experience
-- Focusing on what is best not just for us as individuals, but for the overall
- community
+- Demonstrating empathy and kindness toward other people
+- Being respectful of differing opinions, viewpoints, and experiences
+- Giving and gracefully accepting constructive feedback
+- Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+- Focusing on what is best not just for us as individuals, but for the overall
+ community
Examples of unacceptable behavior include:
-- The use of sexualized language or imagery, and sexual attention or advances of
- any kind
-- Trolling, insulting or derogatory comments, and personal or political attacks
-- Public or private harassment
-- Publishing others' private information, such as a physical or email address,
- without their explicit permission
-- Other conduct which could reasonably be considered inappropriate in a
- professional setting
+- The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+- Trolling, insulting or derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
## Enforcement Responsibilities
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..ffa5dc9
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,133 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+- Demonstrating empathy and kindness toward other people
+- Being respectful of differing opinions, viewpoints, and experiences
+- Giving and gracefully accepting constructive feedback
+- Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+- Focusing on what is best not just for us as individuals, but for the overall
+ community
+
+Examples of unacceptable behavior include:
+
+- The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+- Trolling, insulting or derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official email address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+contact@mfgames.com.
+
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
+
+Community Impact Guidelines were inspired by [Mozilla's code of conduct
+enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
diff --git a/DCO.md b/DCO.md
new file mode 100644
index 0000000..c3782f6
--- /dev/null
+++ b/DCO.md
@@ -0,0 +1,33 @@
+Developer Certificate of Origin
+Version 1.1
+
+Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+(a) The contribution was created in whole or in part by me and I
+have the right to submit it under the open source license
+indicated in the file; or
+
+(b) The contribution is based upon previous work that, to the best
+of my knowledge, is covered under an appropriate open source
+license and I have the right under that license to submit that
+work with modifications, whether created in whole or in part
+by me, under the same open source license (unless I am
+permitted to submit under a different license), as indicated
+in the file; or
+
+(c) The contribution was provided directly to me by some other
+person who certified (a), (b) or (c) and I have not modified
+it.
+
+(d) I understand and agree that this project and the contribution
+are public and that a record of the contribution (including all
+personal information I submit with it, including my sign-off) is
+maintained indefinitely and may be redistributed consistent with
+this project or the open source license(s) involved.
diff --git a/MfGames.sln.DotSettings b/MfGames.sln.DotSettings
index 3fc229d..102460c 100644
--- a/MfGames.sln.DotSettings
+++ b/MfGames.sln.DotSettings
@@ -539,7 +539,7 @@ II.2.12 <HandlesEvent />
UseVarWhenEvidentUseVarWhenEvidentTrue
-
+
False
@@ -663,6 +663,7 @@ II.2.12 <HandlesEvent />
LIVE_MONITORDO_NOTHINGLIVE_MONITOR
+ TrueTrueTrueTrue
diff --git a/docs/index.md b/docs/index.md
index 3976d88..3293fb3 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -2,5 +2,5 @@
## Libraries
-- [Gallium](./gallium/)
-- [Nitride](./nitride/)
+- [Gallium](./gallium/)
+- [Nitride](./nitride/)
diff --git a/examples/NitrideCopyFiles/CopyFilesModule.cs b/examples/NitrideCopyFiles/CopyFilesModule.cs
index 1eefa30..2ddf202 100644
--- a/examples/NitrideCopyFiles/CopyFilesModule.cs
+++ b/examples/NitrideCopyFiles/CopyFilesModule.cs
@@ -4,17 +4,16 @@ namespace NitrideCopyFiles;
public class CopyFilesModule : Module
{
- ///
- protected override void Load(ContainerBuilder builder)
- {
- // This just registers all the non-static classes as singletons
- // within the system. We use lifetimes in other components depending
- // on how they are used, but in this case, we don't need it.
- builder.RegisterAssemblyTypes(
- this.GetType()
- .Assembly)
- .AsSelf()
- .AsImplementedInterfaces()
- .SingleInstance();
- }
+ ///
+ protected override void Load(ContainerBuilder builder)
+ {
+ // This just registers all the non-static classes as singletons
+ // within the system. We use lifetimes in other components depending
+ // on how they are used, but in this case, we don't need it.
+ builder
+ .RegisterAssemblyTypes(this.GetType().Assembly)
+ .AsSelf()
+ .AsImplementedInterfaces()
+ .SingleInstance();
+ }
}
diff --git a/examples/NitrideCopyFiles/CopyFilesPipeline.cs b/examples/NitrideCopyFiles/CopyFilesPipeline.cs
index 7cb06cf..448f2a9 100644
--- a/examples/NitrideCopyFiles/CopyFilesPipeline.cs
+++ b/examples/NitrideCopyFiles/CopyFilesPipeline.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
-
using MfGames.Gallium;
using MfGames.Nitride;
using MfGames.Nitride.IO.Contents;
@@ -16,97 +15,99 @@ namespace NitrideCopyFiles;
///
public class CopyFilesPipeline : PipelineBase
{
- private readonly AddPathPrefix addPathPrefix;
+ private readonly AddPathPrefix addPathPrefix;
- private readonly ClearDirectory clearDirectory;
+ private readonly ClearDirectory clearDirectory;
- private readonly ReadFiles readFiles;
+ private readonly ReadFiles readFiles;
- private readonly RemovePathPrefix removePathPrefix;
+ private readonly RemovePathPrefix removePathPrefix;
- private readonly WriteFiles writeFiles;
+ private readonly WriteFiles writeFiles;
- public CopyFilesPipeline(
- ReadFiles readFiles,
- ClearDirectory clearDirectory,
- WriteFiles writeFiles,
- RemovePathPrefix removePathPrefix,
- AddPathPrefix addPathPrefix)
- {
- // While we can configure these during runtime, it seems cleaner to
- // build them up during the constructor to call out the ones that
- // require runtime data.
- this.readFiles = readFiles.WithPattern("/input/**/*.txt");
- this.clearDirectory = clearDirectory.WithPath("/output");
- this.writeFiles = writeFiles;
- this.removePathPrefix = removePathPrefix.WithPathPrefix("/input");
- this.addPathPrefix = addPathPrefix.WithPathPrefix("/output");
- }
+ public CopyFilesPipeline(
+ ReadFiles readFiles,
+ ClearDirectory clearDirectory,
+ WriteFiles writeFiles,
+ RemovePathPrefix removePathPrefix,
+ AddPathPrefix addPathPrefix
+ )
+ {
+ // While we can configure these during runtime, it seems cleaner to
+ // build them up during the constructor to call out the ones that
+ // require runtime data.
+ this.readFiles = readFiles.WithPattern("/input/**/*.txt");
+ this.clearDirectory = clearDirectory.WithPath("/output");
+ this.writeFiles = writeFiles;
+ this.removePathPrefix = removePathPrefix.WithPathPrefix("/input");
+ this.addPathPrefix = addPathPrefix.WithPathPrefix("/output");
+ }
- ///
- public override IAsyncEnumerable RunAsync(
- IEnumerable _,
- CancellationToken cancellationToken = default)
- {
- // We don't care about the incoming entities which means we can
- // ignore them and use the entities from the ReadFiles operation
- // or we can union the entities pass in with the ReadFiles in case
- // we want to merge them.
- //
- // This will read all the files of the given pattern and return them
- // as an IEnumerable with the Zio components (UPath and
- // binary contents) set. As a note, this doesn't actually read the
- // file, just create a pointer to where the file could be read from.
- //
- // The path component will always be the relative path to the root,
- // so `/input/a.txt` in this case since we only have one file.
- IEnumerable entities = this.readFiles.Run();
+ ///
+ public override IAsyncEnumerable RunAsync(
+ IEnumerable _,
+ CancellationToken cancellationToken = default
+ )
+ {
+ // We don't care about the incoming entities which means we can
+ // ignore them and use the entities from the ReadFiles operation
+ // or we can union the entities pass in with the ReadFiles in case
+ // we want to merge them.
+ //
+ // This will read all the files of the given pattern and return them
+ // as an IEnumerable with the Zio components (UPath and
+ // binary contents) set. As a note, this doesn't actually read the
+ // file, just create a pointer to where the file could be read from.
+ //
+ // The path component will always be the relative path to the root,
+ // so `/input/a.txt` in this case since we only have one file.
+ IEnumerable entities = this.readFiles.Run();
- // Change the path. The path (Zio.UPath component) stays with the
- // entity which is why there is no root directory in the writeFiles
- // operation. Instead, we need to remove the `/input` and replace it
- // with the `/output`.
- //
- // We can do that with a RemovePathPrefix followed by an
- // AddPathPrefix, or use the more complex version of ChangePaths.
- // In this case, we are going for easy to learn, so we'll do the
- // pair.
- //
- // We are going to use the chain extension to make it easier to
- // read. Coming out of this, we will have one entity that fulfills:
- //
- // entity.Get == "/output/a.txt"
- entities = entities
- .Run(this.removePathPrefix, cancellationToken)
- .Run(this.addPathPrefix, cancellationToken);
+ // Change the path. The path (Zio.UPath component) stays with the
+ // entity which is why there is no root directory in the writeFiles
+ // operation. Instead, we need to remove the `/input` and replace it
+ // with the `/output`.
+ //
+ // We can do that with a RemovePathPrefix followed by an
+ // AddPathPrefix, or use the more complex version of ChangePaths.
+ // In this case, we are going for easy to learn, so we'll do the
+ // pair.
+ //
+ // We are going to use the chain extension to make it easier to
+ // read. Coming out of this, we will have one entity that fulfills:
+ //
+ // entity.Get == "/output/a.txt"
+ entities = entities
+ .Run(this.removePathPrefix, cancellationToken)
+ .Run(this.addPathPrefix, cancellationToken);
- // Then we write out the files to the output. First we make sure we
- // clear out the output. This operation performs an action when it
- // it is first entered, but otherwise passes all the inputs through.
- //
- // We can call the clear directory in three ways. The first is to call
- // the operation with:
- //
- // this.clearDirectory.Run()
- //
- // The other is to pass in the entities and get a new list of
- // modified ones out. In this case, clear doesn't make any changes,
- // but Entity objects are immutable, so we always work on the list
- // returned.
- //
- // entities = this.clearDirectory.Run(entity)
- //
- // The third way is to use an extension on entities which lets us
- // chain calls, ala Gulp's pipelines. The below code does this along
- // with writing the files to the output.
- entities = entities
- .Run(this.clearDirectory, cancellationToken)
- .Run(this.writeFiles, cancellationToken);
+ // Then we write out the files to the output. First we make sure we
+ // clear out the output. This operation performs an action when it
+ // it is first entered, but otherwise passes all the inputs through.
+ //
+ // We can call the clear directory in three ways. The first is to call
+ // the operation with:
+ //
+ // this.clearDirectory.Run()
+ //
+ // The other is to pass in the entities and get a new list of
+ // modified ones out. In this case, clear doesn't make any changes,
+ // but Entity objects are immutable, so we always work on the list
+ // returned.
+ //
+ // entities = this.clearDirectory.Run(entity)
+ //
+ // The third way is to use an extension on entities which lets us
+ // chain calls, ala Gulp's pipelines. The below code does this along
+ // with writing the files to the output.
+ entities = entities
+ .Run(this.clearDirectory, cancellationToken)
+ .Run(this.writeFiles, cancellationToken);
- // If we are chaining this pipeline into another, we return the
- // entities. Otherwise, we can just return an empty list. The
- // pipeline is async, so it is wrapped in a task, but most
- // operations are not (or are both).
- return entities.ToAsyncEnumerable();
- }
+ // If we are chaining this pipeline into another, we return the
+ // entities. Otherwise, we can just return an empty list. The
+ // pipeline is async, so it is wrapped in a task, but most
+ // operations are not (or are both).
+ return entities.ToAsyncEnumerable();
+ }
}
diff --git a/examples/NitrideCopyFiles/CopyFilesProgram.cs b/examples/NitrideCopyFiles/CopyFilesProgram.cs
index ba00b3f..8da01a3 100644
--- a/examples/NitrideCopyFiles/CopyFilesProgram.cs
+++ b/examples/NitrideCopyFiles/CopyFilesProgram.cs
@@ -1,8 +1,6 @@
using System.IO;
using System.Threading.Tasks;
-
using Autofac;
-
using MfGames.IO.Extensions;
using MfGames.Nitride;
using MfGames.Nitride.IO.Setup;
@@ -15,41 +13,41 @@ namespace NitrideCopyFiles;
///
public static class CopyFilesProgram
{
- public static async Task Main(string[] args)
- {
- // All of the builder methods are fluent in that they return the
- // builder to allow them to be chained. However, for documentation
- // purposes, we are going to split them apart to explain the details.
- var builder = new NitrideBuilder(args, ConfigureNitride);
+ public static async Task Main(string[] args)
+ {
+ // All of the builder methods are fluent in that they return the
+ // builder to allow them to be chained. However, for documentation
+ // purposes, we are going to split them apart to explain the details.
+ var builder = new NitrideBuilder(args, ConfigureNitride);
- // Filesystem access is provided by Zio, which allows for mutliple
- // folders to be combined together into a single unified file
- // system. At the moment, we set the "root" directory which will
- // contains all the paths, both input and output.
- //
- // Like Serilog, we use a number of extension methods on the builder
- // to inject functionality such as plugins and extensions. In this
- // case, we only need the Nitride.IO module so we use the `UseIO`
- // to inject the requisite modules and configure it.
- DirectoryInfo rootDir = typeof(CopyFilesProgram)
- .GetDirectory()!
- .FindGitRoot()!
- .GetDirectory("examples/NitrideCopyFiles");
+ // Filesystem access is provided by Zio, which allows for mutliple
+ // folders to be combined together into a single unified file
+ // system. At the moment, we set the "root" directory which will
+ // contains all the paths, both input and output.
+ //
+ // Like Serilog, we use a number of extension methods on the builder
+ // to inject functionality such as plugins and extensions. In this
+ // case, we only need the Nitride.IO module so we use the `UseIO`
+ // to inject the requisite modules and configure it.
+ DirectoryInfo rootDir = typeof(CopyFilesProgram)
+ .GetDirectory()!
+ .FindGitRoot()!
+ .GetDirectory("examples/NitrideCopyFiles");
- builder.UseIO(rootDir);
+ builder.UseIO(rootDir);
- // We use Autofac for the bulk of our registration handling. This
- // was mainly because we are more comfortable with Autofac, but it
- // also has a clean interface for handling some of the more esoteric
- // problems we've encountered.
- builder.ConfigureContainer(x => x.RegisterModule());
+ // We use Autofac for the bulk of our registration handling. This
+ // was mainly because we are more comfortable with Autofac, but it
+ // also has a clean interface for handling some of the more esoteric
+ // problems we've encountered.
+ builder.ConfigureContainer(x => x.RegisterModule());
- // Finally, we build the site generator object and run it.
- return await builder.RunAsync();
- }
+ // Finally, we build the site generator object and run it.
+ return await builder.RunAsync();
+ }
- private static void ConfigureNitride(NitrideConfiguration config)
- {
- config.AddLogPipelineCommandLineOption = true;
- }
+ private static void ConfigureNitride(NitrideConfiguration config)
+ {
+ config.AddLogPipelineCommandLineOption = true;
+ }
}
diff --git a/examples/NitridePipelines/NitridePipelinesModule.cs b/examples/NitridePipelines/NitridePipelinesModule.cs
index 21b6eb6..eb34e8e 100644
--- a/examples/NitridePipelines/NitridePipelinesModule.cs
+++ b/examples/NitridePipelines/NitridePipelinesModule.cs
@@ -4,16 +4,16 @@ namespace NitridePipelines;
public class NitridePipelinesModule : Module
{
- ///
- protected override void Load(ContainerBuilder builder)
- {
- // This just registers all the non-static classes as singletons
- // within the system. We use lifetimes in other components depending
- // on how they are used, but in this case, we don't need it.
- builder
- .RegisterAssemblyTypes(this.GetType().Assembly)
- .AsSelf()
- .AsImplementedInterfaces()
- .SingleInstance();
- }
+ ///
+ protected override void Load(ContainerBuilder builder)
+ {
+ // This just registers all the non-static classes as singletons
+ // within the system. We use lifetimes in other components depending
+ // on how they are used, but in this case, we don't need it.
+ builder
+ .RegisterAssemblyTypes(this.GetType().Assembly)
+ .AsSelf()
+ .AsImplementedInterfaces()
+ .SingleInstance();
+ }
}
diff --git a/examples/NitridePipelines/NitridePipelinesProgram.cs b/examples/NitridePipelines/NitridePipelinesProgram.cs
index 14b28a5..f541823 100644
--- a/examples/NitridePipelines/NitridePipelinesProgram.cs
+++ b/examples/NitridePipelines/NitridePipelinesProgram.cs
@@ -1,8 +1,6 @@
using System.IO;
using System.Threading.Tasks;
-
using Autofac;
-
using MfGames.IO.Extensions;
using MfGames.Nitride;
using MfGames.Nitride.IO.Setup;
@@ -15,22 +13,21 @@ namespace NitridePipelines;
///
public static class NitridePipelinesProgram
{
- public static async Task Main(string[] args)
- {
- DirectoryInfo rootDir = typeof(NitridePipelinesProgram)
- .GetDirectory()!
- .FindGitRoot()!
- .GetDirectory("examples/NitridePipelines");
+ public static async Task Main(string[] args)
+ {
+ DirectoryInfo rootDir = typeof(NitridePipelinesProgram)
+ .GetDirectory()!
+ .FindGitRoot()!
+ .GetDirectory("examples/NitridePipelines");
- return await new NitrideBuilder(args, ConfigureNitride)
- .UseIO(rootDir)
- .ConfigureContainer(
- x => x.RegisterModule())
- .RunAsync();
- }
+ return await new NitrideBuilder(args, ConfigureNitride)
+ .UseIO(rootDir)
+ .ConfigureContainer(x => x.RegisterModule())
+ .RunAsync();
+ }
- private static void ConfigureNitride(NitrideConfiguration config)
- {
- config.AddLogPipelineCommandLineOption = true;
- }
+ private static void ConfigureNitride(NitrideConfiguration config)
+ {
+ config.AddLogPipelineCommandLineOption = true;
+ }
}
diff --git a/examples/NitridePipelines/Pipelines/DelayPipeline1.cs b/examples/NitridePipelines/Pipelines/DelayPipeline1.cs
index 8a37fbc..e39a57e 100644
--- a/examples/NitridePipelines/Pipelines/DelayPipeline1.cs
+++ b/examples/NitridePipelines/Pipelines/DelayPipeline1.cs
@@ -2,46 +2,38 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-
using MfGames.Gallium;
using MfGames.Nitride.Pipelines;
-
using Serilog;
-
using Zio;
namespace NitridePipelines.Pipelines;
public class DelayPipeline1 : PipelineBase
{
- private readonly ILogger logger;
+ private readonly ILogger logger;
- public DelayPipeline1(
- ILogger logger,
- InputPipeline1 input1)
- {
- this.logger = logger.ForContext();
- this.AddDependency(input1);
- }
+ public DelayPipeline1(ILogger logger, InputPipeline1 input1)
+ {
+ this.logger = logger.ForContext();
+ this.AddDependency(input1);
+ }
- ///
- public override IAsyncEnumerable RunAsync(
- IEnumerable entities,
- CancellationToken cancellationToken = default)
- {
- entities = entities
- .Select(
- entity =>
- {
- Task.Delay(1000, cancellationToken).Wait(cancellationToken);
+ ///
+ public override IAsyncEnumerable RunAsync(
+ IEnumerable entities,
+ CancellationToken cancellationToken = default
+ )
+ {
+ entities = entities.Select(entity =>
+ {
+ Task.Delay(1000, cancellationToken).Wait(cancellationToken);
- this.logger.Information(
- "Delayed {Value}",
- entity.Get());
+ this.logger.Information("Delayed {Value}", entity.Get());
- return entity;
- });
+ return entity;
+ });
- return entities.ToAsyncEnumerable();
- }
+ return entities.ToAsyncEnumerable();
+ }
}
diff --git a/examples/NitridePipelines/Pipelines/InputPipeline1.cs b/examples/NitridePipelines/Pipelines/InputPipeline1.cs
index ea4e8a9..d762641 100644
--- a/examples/NitridePipelines/Pipelines/InputPipeline1.cs
+++ b/examples/NitridePipelines/Pipelines/InputPipeline1.cs
@@ -2,53 +2,43 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-
using MfGames.Gallium;
using MfGames.Nitride.IO;
using MfGames.Nitride.IO.Contents;
-
using Serilog;
-
using Zio;
namespace NitridePipelines.Pipelines;
public class InputPipeline1 : FileSystemWatchablePipelineBase
{
- private readonly ReadFiles readFiles;
+ private readonly ReadFiles readFiles;
- public InputPipeline1(
- ILogger logger,
- IFileSystem fileSystem,
- ReadFiles readFiles)
- : base(logger, fileSystem)
- {
- this.readFiles = readFiles
- .WithPattern("/input/input1/*.txt");
- }
+ public InputPipeline1(ILogger logger, IFileSystem fileSystem, ReadFiles readFiles)
+ : base(logger, fileSystem)
+ {
+ this.readFiles = readFiles.WithPattern("/input/input1/*.txt");
+ }
- ///
- protected override UPath WatchPath => "/input/input1";
+ ///
+ protected override UPath WatchPath => "/input/input1";
- ///
- public override IAsyncEnumerable RunAsync(
- IEnumerable _,
- CancellationToken cancellationToken = default)
- {
- IEnumerable entities = this.readFiles
- .Run()
- .Select(
- entity =>
- {
- Task.Delay(1000, cancellationToken).Wait(cancellationToken);
+ ///
+ public override IAsyncEnumerable RunAsync(
+ IEnumerable _,
+ CancellationToken cancellationToken = default
+ )
+ {
+ IEnumerable entities = this.readFiles.Run()
+ .Select(entity =>
+ {
+ Task.Delay(1000, cancellationToken).Wait(cancellationToken);
- this.Logger.Information(
- "Read {Value}",
- entity.Get());
+ this.Logger.Information("Read {Value}", entity.Get());
- return entity;
- });
+ return entity;
+ });
- return entities.ToAsyncEnumerable();
- }
+ return entities.ToAsyncEnumerable();
+ }
}
diff --git a/examples/NitridePipelines/Pipelines/InputPipeline2.cs b/examples/NitridePipelines/Pipelines/InputPipeline2.cs
index 80fe839..d7e5bd1 100644
--- a/examples/NitridePipelines/Pipelines/InputPipeline2.cs
+++ b/examples/NitridePipelines/Pipelines/InputPipeline2.cs
@@ -2,56 +2,46 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-
using MfGames.Gallium;
using MfGames.Nitride.IO;
using MfGames.Nitride.IO.Contents;
-
using Serilog;
-
using Zio;
namespace NitridePipelines.Pipelines;
public class InputPipeline2 : FileSystemWatchablePipelineBase
{
- private readonly ILogger logger;
+ private readonly ILogger logger;
- private readonly ReadFiles readFiles;
+ private readonly ReadFiles readFiles;
- public InputPipeline2(
- ILogger logger,
- IFileSystem fileSystem,
- ReadFiles readFiles)
- : base(logger, fileSystem)
- {
- this.logger = logger.ForContext();
- this.readFiles = readFiles
- .WithPattern("/input/input2/*.txt");
- }
+ public InputPipeline2(ILogger logger, IFileSystem fileSystem, ReadFiles readFiles)
+ : base(logger, fileSystem)
+ {
+ this.logger = logger.ForContext();
+ this.readFiles = readFiles.WithPattern("/input/input2/*.txt");
+ }
- ///
- protected override UPath WatchPath => "/input/input2";
+ ///
+ protected override UPath WatchPath => "/input/input2";
- ///
- public override IAsyncEnumerable RunAsync(
- IEnumerable _,
- CancellationToken cancellationToken = default)
- {
- IEnumerable entities = this.readFiles
- .Run()
- .Select(
- entity =>
- {
- Task.Delay(1000, cancellationToken).Wait(cancellationToken);
+ ///
+ public override IAsyncEnumerable RunAsync(
+ IEnumerable _,
+ CancellationToken cancellationToken = default
+ )
+ {
+ IEnumerable entities = this.readFiles.Run()
+ .Select(entity =>
+ {
+ Task.Delay(1000, cancellationToken).Wait(cancellationToken);
- this.logger.Information(
- "Read {Value}",
- entity.Get());
+ this.logger.Information("Read {Value}", entity.Get());
- return entity;
- });
+ return entity;
+ });
- return entities.ToAsyncEnumerable();
- }
+ return entities.ToAsyncEnumerable();
+ }
}
diff --git a/examples/NitridePipelines/Pipelines/OutputPipeline1.cs b/examples/NitridePipelines/Pipelines/OutputPipeline1.cs
index ef485c8..1e55083 100644
--- a/examples/NitridePipelines/Pipelines/OutputPipeline1.cs
+++ b/examples/NitridePipelines/Pipelines/OutputPipeline1.cs
@@ -2,47 +2,38 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-
using MfGames.Gallium;
using MfGames.Nitride.Pipelines;
-
using Serilog;
-
using Zio;
namespace NitridePipelines.Pipelines;
public class OutputPipeline1 : PipelineBase
{
- private readonly ILogger logger;
+ private readonly ILogger logger;
- public OutputPipeline1(
- ILogger logger,
- DelayPipeline1 delay1,
- InputPipeline2 input2)
- {
- this.logger = logger.ForContext();
- this.AddDependency(delay1, input2);
- }
+ public OutputPipeline1(ILogger logger, DelayPipeline1 delay1, InputPipeline2 input2)
+ {
+ this.logger = logger.ForContext();
+ this.AddDependency(delay1, input2);
+ }
- ///
- public override IAsyncEnumerable RunAsync(
- IEnumerable entities,
- CancellationToken cancellationToken = default)
- {
- entities = entities
- .Select(
- entity =>
- {
- Task.Delay(1000, cancellationToken).Wait(cancellationToken);
+ ///
+ public override IAsyncEnumerable RunAsync(
+ IEnumerable entities,
+ CancellationToken cancellationToken = default
+ )
+ {
+ entities = entities.Select(entity =>
+ {
+ Task.Delay(1000, cancellationToken).Wait(cancellationToken);
- this.logger.Information(
- "Pretended to write {Value}",
- entity.Get());
+ this.logger.Information("Pretended to write {Value}", entity.Get());
- return entity;
- });
+ return entity;
+ });
- return entities.ToAsyncEnumerable();
- }
+ return entities.ToAsyncEnumerable();
+ }
}
diff --git a/examples/NitridePipelines/Pipelines/OutputPipeline2.cs b/examples/NitridePipelines/Pipelines/OutputPipeline2.cs
index e05863b..4974937 100644
--- a/examples/NitridePipelines/Pipelines/OutputPipeline2.cs
+++ b/examples/NitridePipelines/Pipelines/OutputPipeline2.cs
@@ -2,46 +2,38 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-
using MfGames.Gallium;
using MfGames.Nitride.Pipelines;
-
using Serilog;
-
using Zio;
namespace NitridePipelines.Pipelines;
public class OutputPipeline2 : PipelineBase
{
- private readonly ILogger logger;
+ private readonly ILogger logger;
- public OutputPipeline2(
- ILogger logger,
- InputPipeline2 input2)
- {
- this.logger = logger.ForContext();
- this.AddDependency(input2);
- }
+ public OutputPipeline2(ILogger logger, InputPipeline2 input2)
+ {
+ this.logger = logger.ForContext();
+ this.AddDependency(input2);
+ }
- ///
- public override IAsyncEnumerable RunAsync(
- IEnumerable entities,
- CancellationToken cancellationToken = default)
- {
- entities = entities
- .Select(
- entity =>
- {
- Task.Delay(1000, cancellationToken).Wait(cancellationToken);
+ ///
+ public override IAsyncEnumerable RunAsync(
+ IEnumerable entities,
+ CancellationToken cancellationToken = default
+ )
+ {
+ entities = entities.Select(entity =>
+ {
+ Task.Delay(1000, cancellationToken).Wait(cancellationToken);
- this.logger.Information(
- "Pretended to write {Value}",
- entity.Get());
+ this.logger.Information("Pretended to write {Value}", entity.Get());
- return entity;
- });
+ return entity;
+ });
- return entities.ToAsyncEnumerable();
- }
+ return entities.ToAsyncEnumerable();
+ }
}
diff --git a/examples/SampleTool/Commands/ConfigCommand.cs b/examples/SampleTool/Commands/ConfigCommand.cs
index 9b729fa..c2e57ec 100644
--- a/examples/SampleTool/Commands/ConfigCommand.cs
+++ b/examples/SampleTool/Commands/ConfigCommand.cs
@@ -2,88 +2,77 @@ using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading.Tasks;
-
using MfGames.ToolBuilder;
using MfGames.ToolBuilder.Config;
-
using Microsoft.Extensions.Logging;
-
using Newtonsoft.Json;
namespace SampleTool.Commands;
public class ConfigCommand : Command, ICommandHandler, ITopCommand
{
- private readonly ILogger logger;
+ private readonly ILogger logger;
- private readonly ConfigToolService service;
+ private readonly ConfigToolService service;
- private readonly Option setOption;
+ private readonly Option setOption;
- ///
- public ConfigCommand(
- ILoggerFactory loggerFactory,
- ConfigToolService service)
- : base(
- "config",
- "Sets and displays the configuration settings")
- {
- this.logger = loggerFactory.CreateLogger();
- this.service = service;
- this.Handler = this;
+ ///
+ public ConfigCommand(ILoggerFactory loggerFactory, ConfigToolService service)
+ : base("config", "Sets and displays the configuration settings")
+ {
+ this.logger = loggerFactory.CreateLogger();
+ this.service = service;
+ this.Handler = this;
- this.setOption = new Option(
- "--set",
- "Sets the text value in the setting");
+ this.setOption = new Option("--set", "Sets the text value in the setting");
- this.AddOption(this.setOption);
- }
+ this.AddOption(this.setOption);
+ }
- ///
- public int Invoke(InvocationContext context)
- {
- return this.InvokeAsync(context).Result;
- }
+ ///
+ public int Invoke(InvocationContext context)
+ {
+ return this.InvokeAsync(context).Result;
+ }
- ///
- public Task InvokeAsync(InvocationContext context)
- {
- // Get the settings and report that it was being created.
- ConfigCommandSettings settings =
- this.service.ReadDefaultConfigFile();
+ ///
+ public Task InvokeAsync(InvocationContext context)
+ {
+ // Get the settings and report that it was being created.
+ ConfigCommandSettings settings =
+ this.service.ReadDefaultConfigFile();
- if (settings == null)
- {
- this.logger.LogInformation("Creating configuration file");
- settings = new ConfigCommandSettings();
- }
+ if (settings == null)
+ {
+ this.logger.LogInformation("Creating configuration file");
+ settings = new ConfigCommandSettings();
+ }
- // If we have a set command, then provide it.
- string value = context.ParseResult
- .GetValueForOption(this.setOption);
+ // If we have a set command, then provide it.
+ string value = context.ParseResult.GetValueForOption(this.setOption);
- if (value != null)
- {
- settings.Value = value;
- }
+ if (value != null)
+ {
+ settings.Value = value;
+ }
- // Increment the counter.
- settings.TimesRead++;
+ // Increment the counter.
+ settings.TimesRead++;
- // Report the values.
- Console.WriteLine(
- JsonConvert.SerializeObject(settings, Formatting.Indented));
+ // Report the values.
+ Console.WriteLine(JsonConvert.SerializeObject(settings, Formatting.Indented));
- // Write out the settings.
- this.service.WriteDefaultConfigFile(settings);
+ // Write out the settings.
+ this.service.WriteDefaultConfigFile(settings);
- return Task.FromResult(0);
- }
+ return Task.FromResult(0);
+ }
- private class ConfigCommandSettings
- {
- public int TimesRead { get; set; }
+ private class ConfigCommandSettings
+ {
+ public int TimesRead { get; set; }
- public string Value { get; set; }
- }
+ public string Value { get; set; }
+ }
}
diff --git a/examples/SampleTool/Commands/CrashCommand.cs b/examples/SampleTool/Commands/CrashCommand.cs
index 22a82a9..bdc37c0 100644
--- a/examples/SampleTool/Commands/CrashCommand.cs
+++ b/examples/SampleTool/Commands/CrashCommand.cs
@@ -2,42 +2,40 @@ using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading.Tasks;
-
using MfGames.ToolBuilder;
namespace SampleTool.Commands;
public class CrashCommand : Command, ICommandHandler, ITopCommand
{
- private readonly Option messyOption;
+ private readonly Option messyOption;
- ///
- public CrashCommand()
- : base("crash", "Crash the application with an exception")
- {
- this.Handler = this;
- this.messyOption = new Option("--messy");
+ ///
+ public CrashCommand()
+ : base("crash", "Crash the application with an exception")
+ {
+ this.Handler = this;
+ this.messyOption = new Option("--messy");
- this.AddOption(this.messyOption);
- }
+ this.AddOption(this.messyOption);
+ }
- ///
- public int Invoke(InvocationContext context)
- {
- return this.InvokeAsync(context).Result;
- }
+ ///
+ public int Invoke(InvocationContext context)
+ {
+ return this.InvokeAsync(context).Result;
+ }
- ///
- public Task InvokeAsync(InvocationContext context)
- {
- bool messy = context.ParseResult.GetValueForOption(this.messyOption);
+ ///
+ public Task InvokeAsync(InvocationContext context)
+ {
+ bool messy = context.ParseResult.GetValueForOption(this.messyOption);
- if (messy)
- {
- throw new Exception(
- "This command crashed messily as requested.");
- }
+ if (messy)
+ {
+ throw new Exception("This command crashed messily as requested.");
+ }
- throw new ToolException("This command crashed as requested.");
- }
+ throw new ToolException("This command crashed as requested.");
+ }
}
diff --git a/examples/SampleTool/Commands/LogCommand.cs b/examples/SampleTool/Commands/LogCommand.cs
index ed6e17a..df41d5c 100644
--- a/examples/SampleTool/Commands/LogCommand.cs
+++ b/examples/SampleTool/Commands/LogCommand.cs
@@ -1,97 +1,84 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading.Tasks;
-
using MfGames.ToolBuilder;
-
using Microsoft.Extensions.Logging;
-
using ILogger = Serilog.ILogger;
namespace SampleTool.Commands;
public class LogCommand : Command, ICommandHandler, ITopCommand
{
- private readonly ILogger extensionLogger;
+ private readonly ILogger extensionLogger;
- private readonly ILogger serilogContextLogger;
+ private readonly ILogger serilogContextLogger;
- private readonly ILogger serilogLogger;
+ private readonly ILogger serilogLogger;
- ///
- public LogCommand(
- ILoggerFactory loggerFactory,
- ILogger serilogLogger)
- : base(
- "log",
- "Shows various logging messages using Serilog and Microsoft")
- {
- this.serilogLogger = serilogLogger;
- this.serilogContextLogger = serilogLogger.ForContext();
- this.extensionLogger = loggerFactory.CreateLogger();
- this.Handler = this;
- }
+ ///
+ public LogCommand(ILoggerFactory loggerFactory, ILogger serilogLogger)
+ : base("log", "Shows various logging messages using Serilog and Microsoft")
+ {
+ this.serilogLogger = serilogLogger;
+ this.serilogContextLogger = serilogLogger.ForContext();
+ this.extensionLogger = loggerFactory.CreateLogger();
+ this.Handler = this;
+ }
- ///
- public int Invoke(InvocationContext context)
- {
- return this.InvokeAsync(context).Result;
- }
+ ///
+ public int Invoke(InvocationContext context)
+ {
+ return this.InvokeAsync(context).Result;
+ }
- ///
- public Task InvokeAsync(InvocationContext context)
- {
- // Show the serilog logging.
- this.serilogLogger.Verbose("Serilog Verbose()");
- this.serilogLogger.Debug("Serilog Debug()");
- this.serilogLogger.Information("Serilog Information()");
- this.serilogLogger.Warning("Serilog Warning()");
- this.serilogLogger.Error("Serilog Error()");
- this.serilogLogger.Fatal("Serilog Fatal()");
+ ///
+ public Task InvokeAsync(InvocationContext context)
+ {
+ // Show the serilog logging.
+ this.serilogLogger.Verbose("Serilog Verbose()");
+ this.serilogLogger.Debug("Serilog Debug()");
+ this.serilogLogger.Information("Serilog Information()");
+ this.serilogLogger.Warning("Serilog Warning()");
+ this.serilogLogger.Error("Serilog Error()");
+ this.serilogLogger.Fatal("Serilog Fatal()");
- // Show serilog with context.
- this.serilogContextLogger.Information(
- "Serilog Information() with context");
+ // Show serilog with context.
+ this.serilogContextLogger.Information("Serilog Information() with context");
- // Show the extension logging.
- this.extensionLogger.LogTrace(
- "System.Extension.Logging LogTrace");
- this.extensionLogger.LogDebug(
- "System.Extension.Logging LogDebug");
- this.extensionLogger.LogInformation(
- "System.Extension.Logging LogInformation");
- this.extensionLogger.LogWarning(
- "System.Extension.Logging LogWarning");
- this.extensionLogger.LogError(
- "System.Extension.Logging LogError");
- this.extensionLogger.LogCritical(
- "System.Extension.Logging LogCritical");
+ // Show the extension logging.
+ this.extensionLogger.LogTrace("System.Extension.Logging LogTrace");
+ this.extensionLogger.LogDebug("System.Extension.Logging LogDebug");
+ this.extensionLogger.LogInformation("System.Extension.Logging LogInformation");
+ this.extensionLogger.LogWarning("System.Extension.Logging LogWarning");
+ this.extensionLogger.LogError("System.Extension.Logging LogError");
+ this.extensionLogger.LogCritical("System.Extension.Logging LogCritical");
- // Show Serilog working through logging extensions.
- var hash = new
- {
- Number = 1,
- String = "String",
- Inner = new { Nested = true }
- };
+ // Show Serilog working through logging extensions.
+ var hash = new
+ {
+ Number = 1,
+ String = "String",
+ Inner = new { Nested = true }
+ };
- this.serilogLogger.Information(
- "Serilog Contextual parameters {Name} and {Quotes:l}",
- "extension logger",
- "without quotes");
- this.serilogLogger.Information(
- "Serilog Contextual nested object {@Nested}",
- hash);
+ this.serilogLogger.Information(
+ "Serilog Contextual parameters {Name} and {Quotes:l}",
+ "extension logger",
+ "without quotes"
+ );
+ this.serilogLogger.Information("Serilog Contextual nested object {@Nested}", hash);
- this.extensionLogger.LogInformation(
- "System.Extension.Logging parameters {Name} and {Quotes:l}",
- "extension logger",
- "without quotes");
- this.extensionLogger.LogInformation(
- "System.Extension.Logging nested object {@Nested}",
- hash);
+ this.extensionLogger.LogInformation(
+ "System.Extension.Logging parameters {Name} and {Quotes:l}",
+ "extension logger",
+ "without quotes"
+ );
+ this.extensionLogger.LogInformation(
+ "System.Extension.Logging nested object {@Nested}",
+ hash
+ );
- // We're good.
- return Task.FromResult(0);
- }
+ // We're good.
+ return Task.FromResult(0);
+ }
}
diff --git a/examples/SampleTool/Commands/SpectreCommand.cs b/examples/SampleTool/Commands/SpectreCommand.cs
index 5c24e55..577e239 100644
--- a/examples/SampleTool/Commands/SpectreCommand.cs
+++ b/examples/SampleTool/Commands/SpectreCommand.cs
@@ -11,81 +11,77 @@ using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
-
using MfGames.ToolBuilder;
-
using Microsoft.Extensions.Logging;
-
using Spectre.Console;
namespace SampleTool.Commands;
public class SpectreCommand : Command, ICommandHandler, ITopCommand
{
- private readonly ILogger logger;
+ private readonly ILogger logger;
- ///
- public SpectreCommand(ILoggerFactory loggerFactory)
- : base("spectre", "Shows various SpectreConsole features")
- {
- this.logger = loggerFactory.CreateLogger();
- this.Handler = this;
- }
+ ///
+ public SpectreCommand(ILoggerFactory loggerFactory)
+ : base("spectre", "Shows various SpectreConsole features")
+ {
+ this.logger = loggerFactory.CreateLogger();
+ this.Handler = this;
+ }
- ///
- public int Invoke(InvocationContext context)
- {
- return this.InvokeAsync(context).Result;
- }
+ ///
+ public int Invoke(InvocationContext context)
+ {
+ return this.InvokeAsync(context).Result;
+ }
- ///
- public async Task InvokeAsync(InvocationContext context)
- {
- // Display a message ahead of this.
- this.logger.LogInformation("Before things happened.");
+ ///
+ public async Task InvokeAsync(InvocationContext context)
+ {
+ // Display a message ahead of this.
+ this.logger.LogInformation("Before things happened.");
- // Show a progress bar.
- CancellationToken cancellationToken = context.GetCancellationToken();
- DateTime last = DateTime.UtcNow;
+ // Show a progress bar.
+ CancellationToken cancellationToken = context.GetCancellationToken();
+ DateTime last = DateTime.UtcNow;
- await AnsiConsole.Progress()
- .AutoClear(true)
- .StartAsync(
- async ctx =>
- {
- ProgressTask task1 = ctx.AddTask("[green]Fast Task[/]");
- ProgressTask task2 = ctx.AddTask("[green]Slow Task[/]");
+ await AnsiConsole
+ .Progress()
+ .AutoClear(true)
+ .StartAsync(async ctx =>
+ {
+ ProgressTask task1 = ctx.AddTask("[green]Fast Task[/]");
+ ProgressTask task2 = ctx.AddTask("[green]Slow Task[/]");
- while (!ctx.IsFinished)
- {
- // See if we're cancelled.
- if (cancellationToken.IsCancellationRequested)
- {
- break;
- }
+ while (!ctx.IsFinished)
+ {
+ // See if we're cancelled.
+ if (cancellationToken.IsCancellationRequested)
+ {
+ break;
+ }
- // Simulate some work
- await Task.Delay(25, cancellationToken);
+ // Simulate some work
+ await Task.Delay(25, cancellationToken);
- if (DateTime.UtcNow - last
- > TimeSpan.FromMilliseconds(500))
- {
- this.logger.LogWarning("Working...");
- last = DateTime.UtcNow;
- }
+ if (DateTime.UtcNow - last > TimeSpan.FromMilliseconds(500))
+ {
+ this.logger.LogWarning("Working...");
+ last = DateTime.UtcNow;
+ }
- await Task.Delay(25, cancellationToken);
+ await Task.Delay(25, cancellationToken);
- // Increment
- task1.Increment(2.0);
- task2.Increment(1.0);
- }
- });
+ // Increment
+ task1.Increment(2.0);
+ task2.Increment(1.0);
+ }
+ });
- // Report we're done.
- this.logger.LogInformation("Done");
+ // Report we're done.
+ this.logger.LogInformation("Done");
- return 0;
- }
+ return 0;
+ }
}
#endif
diff --git a/examples/SampleTool/Commands/TableCommand.cs b/examples/SampleTool/Commands/TableCommand.cs
index 4633905..961e481 100644
--- a/examples/SampleTool/Commands/TableCommand.cs
+++ b/examples/SampleTool/Commands/TableCommand.cs
@@ -3,7 +3,6 @@ using System.CommandLine;
using System.CommandLine.Invocation;
using System.Data;
using System.Threading.Tasks;
-
using MfGames.ToolBuilder;
using MfGames.ToolBuilder.Tables;
@@ -11,49 +10,46 @@ namespace SampleTool.Commands;
public class TableCommand : Command, ICommandHandler, ITopCommand
{
- private readonly DataTable table;
+ private readonly DataTable table;
- private readonly TableToolService tableService;
+ private readonly TableToolService tableService;
- ///
- public TableCommand(TableToolService.Factory tableService)
- : base("table", "Display a Markdown table")
- {
- // Create the table structure.
- this.table = new DataTable();
- this.table.Columns.Add("DefaultString", typeof(string));
- this.table.Columns.Add("DefaultInt32", typeof(int));
- this.table.Columns.Add("HiddenString", typeof(string));
+ ///
+ public TableCommand(TableToolService.Factory tableService)
+ : base("table", "Display a Markdown table")
+ {
+ // Create the table structure.
+ this.table = new DataTable();
+ this.table.Columns.Add("DefaultString", typeof(string));
+ this.table.Columns.Add("DefaultInt32", typeof(int));
+ this.table.Columns.Add("HiddenString", typeof(string));
- // Create the table service for formatting and displaying results.
- this.tableService = tableService(
- this.table,
- new List
- {
- "DefaultString",
- "DefaultInt32",
- })
- .Attach(this);
+ // Create the table service for formatting and displaying results.
+ this.tableService = tableService(
+ this.table,
+ new List { "DefaultString", "DefaultInt32", }
+ )
+ .Attach(this);
- // This class handles the command.
- this.Handler = this;
- }
+ // This class handles the command.
+ this.Handler = this;
+ }
- ///
- public int Invoke(InvocationContext context)
- {
- return this.InvokeAsync(context).Result;
- }
+ ///
+ public int Invoke(InvocationContext context)
+ {
+ return this.InvokeAsync(context).Result;
+ }
- ///
- public Task InvokeAsync(InvocationContext context)
- {
- this.table.Rows.Add("Row 1", 1, "Hidden 1");
- this.table.Rows.Add("Row 2", 10, "Hidden 2");
- this.table.Rows.Add("Row 3", 100, "Hidden 3");
+ ///
+ public Task InvokeAsync(InvocationContext context)
+ {
+ this.table.Rows.Add("Row 1", 1, "Hidden 1");
+ this.table.Rows.Add("Row 2", 10, "Hidden 2");
+ this.table.Rows.Add("Row 3", 100, "Hidden 3");
- this.tableService.Write(context);
+ this.tableService.Write(context);
- return Task.FromResult(0);
- }
+ return Task.FromResult(0);
+ }
}
diff --git a/examples/SampleTool/Program.cs b/examples/SampleTool/Program.cs
index 77b4634..34fb7f4 100644
--- a/examples/SampleTool/Program.cs
+++ b/examples/SampleTool/Program.cs
@@ -1,7 +1,5 @@
using System.Threading.Tasks;
-
using Autofac;
-
using MfGames.ToolBuilder;
using MfGames.ToolBuilder.Config;
using MfGames.ToolBuilder.Tables;
@@ -10,19 +8,19 @@ namespace SampleTool;
public static class Program
{
- public static async Task Main(string[] args)
- {
- return await ToolBoxBuilder
- .Create(args)
- .UseUserConfiguration("mfgames-toolbuilder-sample")
- .ConfigureContainer(ConfigureContainer)
- .Build()
- .RunAsync();
- }
+ public static async Task Main(string[] args)
+ {
+ return await ToolBoxBuilder
+ .Create(args)
+ .UseUserConfiguration("mfgames-toolbuilder-sample")
+ .ConfigureContainer(ConfigureContainer)
+ .Build()
+ .RunAsync();
+ }
- private static void ConfigureContainer(ContainerBuilder builder)
- {
- builder.RegisterModule();
- builder.RegisterModule();
- }
+ private static void ConfigureContainer(ContainerBuilder builder)
+ {
+ builder.RegisterModule();
+ builder.RegisterModule();
+ }
}
diff --git a/examples/SampleTool/SampleToolModule.cs b/examples/SampleTool/SampleToolModule.cs
index 4a428fc..a80e9c2 100644
--- a/examples/SampleTool/SampleToolModule.cs
+++ b/examples/SampleTool/SampleToolModule.cs
@@ -2,9 +2,7 @@ using System;
using System.Collections.Generic;
using System.CommandLine;
using System.Linq;
-
using Autofac;
-
using MfGames.ToolBuilder;
namespace SampleTool;
@@ -14,44 +12,38 @@ namespace SampleTool;
///
public class SampleToolModule : Module
{
- ///
- protected override void Load(ContainerBuilder builder)
- {
- builder
- .RegisterAssemblyTypes(this.GetType().Assembly)
- .AsSelf()
- .AsImplementedInterfaces();
+ ///
+ protected override void Load(ContainerBuilder builder)
+ {
+ builder.RegisterAssemblyTypes(this.GetType().Assembly).AsSelf().AsImplementedInterfaces();
- builder
- .Register(
- c =>
- {
- // Create the top-level command.
- var root = new RootCommand
- {
- Name = "sample-tool",
- Description =
- "A sample tool that demonstrates functionality",
- };
+ builder
+ .Register(c =>
+ {
+ // Create the top-level command.
+ var root = new RootCommand
+ {
+ Name = "sample-tool",
+ Description = "A sample tool that demonstrates functionality",
+ };
- // Add in the top-level commands.
- var commandList = c.Resolve>()
- .Cast()
- .ToList();
+ // Add in the top-level commands.
+ var commandList = c.Resolve>().Cast().ToList();
- if (commandList.Count == 0)
- {
- throw new InvalidOperationException(
- "Cannot create a tool without at least one command extending System.CommandLine.Command");
- }
+ if (commandList.Count == 0)
+ {
+ throw new InvalidOperationException(
+ "Cannot create a tool without at least one command extending System.CommandLine.Command"
+ );
+ }
- foreach (Command command in commandList)
- {
- root.AddCommand(command);
- }
+ foreach (Command command in commandList)
+ {
+ root.AddCommand(command);
+ }
- return root;
- })
- .AsSelf();
- }
+ return root;
+ })
+ .AsSelf();
+ }
}
diff --git a/flake.lock b/flake.lock
index 2df02ca..c91662a 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,136 +1,12 @@
{
"nodes": {
- "blank": {
- "locked": {
- "lastModified": 1625557891,
- "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=",
- "owner": "divnix",
- "repo": "blank",
- "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8",
- "type": "github"
- },
- "original": {
- "owner": "divnix",
- "repo": "blank",
- "type": "github"
- }
- },
- "crane": {
- "inputs": {
- "flake-compat": "flake-compat",
- "flake-utils": "flake-utils_2",
- "nixpkgs": [
- "std",
- "paisano-mdbook-preprocessor",
- "nixpkgs"
- ],
- "rust-overlay": "rust-overlay"
- },
- "locked": {
- "lastModified": 1676162383,
- "narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=",
- "owner": "ipetkov",
- "repo": "crane",
- "rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2",
- "type": "github"
- },
- "original": {
- "owner": "ipetkov",
- "repo": "crane",
- "type": "github"
- }
- },
- "devshell": {
- "inputs": {
- "flake-utils": [
- "std",
- "flake-utils"
- ],
- "nixpkgs": [
- "std",
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1682700442,
- "narHash": "sha256-qjaAAcCYgp1pBBG7mY9z95ODUBZMtUpf0Qp3Gt/Wha0=",
- "owner": "numtide",
- "repo": "devshell",
- "rev": "fb6673fe9fe4409e3f43ca86968261e970918a83",
- "type": "github"
- },
- "original": {
- "owner": "numtide",
- "repo": "devshell",
- "type": "github"
- }
- },
- "dmerge": {
- "inputs": {
- "haumea": "haumea",
- "nixlib": "nixlib",
- "yants": [
- "std",
- "yants"
- ]
- },
- "locked": {
- "lastModified": 1686862774,
- "narHash": "sha256-ojGtRQ9pIOUrxsQEuEPerUkqIJEuod9hIflfNkY+9CE=",
- "owner": "divnix",
- "repo": "dmerge",
- "rev": "9f7f7a8349d33d7bd02e0f2b484b1f076e503a96",
- "type": "github"
- },
- "original": {
- "owner": "divnix",
- "ref": "0.2.1",
- "repo": "dmerge",
- "type": "github"
- }
- },
- "fenix": {
- "inputs": {
- "nixpkgs": "nixpkgs_2",
- "rust-analyzer-src": "rust-analyzer-src"
- },
- "locked": {
- "lastModified": 1677306201,
- "narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=",
- "owner": "nix-community",
- "repo": "fenix",
- "rev": "0923f0c162f65ae40261ec940406049726cfeab4",
- "type": "github"
- },
- "original": {
- "owner": "nix-community",
- "repo": "fenix",
- "type": "github"
- }
- },
- "flake-compat": {
- "flake": false,
- "locked": {
- "lastModified": 1673956053,
- "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
- "owner": "edolstra",
- "repo": "flake-compat",
- "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
- "type": "github"
- },
- "original": {
- "owner": "edolstra",
- "repo": "flake-compat",
- "type": "github"
- }
- },
"flake-utils": {
"locked": {
- "lastModified": 1659877975,
- "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
@@ -141,11 +17,11 @@
},
"flake-utils_2": {
"locked": {
- "lastModified": 1667395993,
- "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
@@ -154,97 +30,296 @@
"type": "github"
}
},
- "haumea": {
- "inputs": {
- "nixpkgs": [
- "std",
- "dmerge",
- "nixlib"
- ]
- },
+ "flake-utils_3": {
"locked": {
- "lastModified": 1685133229,
- "narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=",
- "owner": "nix-community",
- "repo": "haumea",
- "rev": "34dd58385092a23018748b50f9b23de6266dffc2",
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
- "owner": "nix-community",
- "ref": "v0.2.2",
- "repo": "haumea",
+ "owner": "numtide",
+ "repo": "flake-utils",
"type": "github"
}
},
- "incl": {
- "inputs": {
- "nixlib": [
- "std",
- "dmerge",
- "nixlib"
- ]
- },
+ "flake-utils_4": {
"locked": {
- "lastModified": 1669263024,
- "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=",
- "owner": "divnix",
- "repo": "incl",
- "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca",
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
- "owner": "divnix",
- "repo": "incl",
+ "owner": "numtide",
+ "repo": "flake-utils",
"type": "github"
}
},
- "n2c": {
- "inputs": {
- "flake-utils": [
- "std",
- "flake-utils"
- ],
- "nixpkgs": [
- "std",
- "nixpkgs"
- ]
- },
+ "flake-utils_5": {
"locked": {
- "lastModified": 1685771919,
- "narHash": "sha256-3lVKWrhNXjHJB6QkZ2SJaOs4X/mmYXtY6ovPVpDMOHc=",
- "owner": "nlewo",
- "repo": "nix2container",
- "rev": "95e2220911874064b5d809f8d35f7835184c4ddf",
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
- "owner": "nlewo",
- "repo": "nix2container",
+ "owner": "numtide",
+ "repo": "flake-utils",
"type": "github"
}
},
+ "flake-utils_6": {
+ "locked": {
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_7": {
+ "locked": {
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_8": {
+ "locked": {
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_9": {
+ "locked": {
+ "lastModified": 1653893745,
+ "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "mfgames-project-setup": {
+ "inputs": {
+ "nixago": "nixago",
+ "nixago-exts": "nixago-exts_3",
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1709701991,
+ "narHash": "sha256-aioBatPisIMfmVUq50g9M74GidTqgRpA+PVXuL6NYAo=",
+ "ref": "refs/heads/main",
+ "rev": "9c50fe4984c346cec825c2875e1ba81ec385f5b1",
+ "revCount": 15,
+ "type": "git",
+ "url": "https://src.mfgames.com/nixos-contrib/mfgames-project-setup-flake.git"
+ },
+ "original": {
+ "type": "git",
+ "url": "https://src.mfgames.com/nixos-contrib/mfgames-project-setup-flake.git"
+ }
+ },
"nixago": {
"inputs": {
- "flake-utils": [
- "std",
- "flake-utils"
- ],
- "nixago-exts": [
- "std",
- "blank"
- ],
+ "flake-utils": "flake-utils",
+ "nixago-exts": "nixago-exts",
"nixpkgs": [
- "std",
+ "mfgames-project-setup",
"nixpkgs"
]
},
"locked": {
- "lastModified": 1683210100,
- "narHash": "sha256-bhGDOlkWtlhVECpoOog4fWiFJmLCpVEg09a40aTjCbw=",
+ "lastModified": 1687381756,
+ "narHash": "sha256-IUMIlYfrvj7Yli4H2vvyig8HEPpfCeMaE6+kBGPzFyk=",
+ "owner": "jmgilman",
+ "repo": "nixago",
+ "rev": "dacceb10cace103b3e66552ec9719fa0d33c0dc9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "jmgilman",
+ "repo": "nixago",
+ "type": "github"
+ }
+ },
+ "nixago-exts": {
+ "inputs": {
+ "flake-utils": "flake-utils_2",
+ "nixago": "nixago_2",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1676070308,
+ "narHash": "sha256-QaJ65oc2l8iwQIGWUJ0EKjCeSuuCM/LqR8RauxZUUkc=",
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "rev": "e5380cb0456f4ea3c86cf94e3039eb856bf07d0b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "type": "github"
+ }
+ },
+ "nixago-exts_2": {
+ "inputs": {
+ "flake-utils": "flake-utils_4",
+ "nixago": "nixago_3",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago",
+ "nixago-exts",
+ "nixago",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1655508669,
+ "narHash": "sha256-BDDdo5dZQMmwNH/GNacy33nPBnCpSIydWFPZs0kkj/g=",
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "rev": "3022a932ce109258482ecc6568c163e8d0b426aa",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "type": "github"
+ }
+ },
+ "nixago-exts_3": {
+ "inputs": {
+ "flake-utils": "flake-utils_6",
+ "nixago": "nixago_4",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1676070308,
+ "narHash": "sha256-QaJ65oc2l8iwQIGWUJ0EKjCeSuuCM/LqR8RauxZUUkc=",
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "rev": "e5380cb0456f4ea3c86cf94e3039eb856bf07d0b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "type": "github"
+ }
+ },
+ "nixago-exts_4": {
+ "inputs": {
+ "flake-utils": "flake-utils_8",
+ "nixago": "nixago_5",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago-exts",
+ "nixago",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1655508669,
+ "narHash": "sha256-BDDdo5dZQMmwNH/GNacy33nPBnCpSIydWFPZs0kkj/g=",
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "rev": "3022a932ce109258482ecc6568c163e8d0b426aa",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixago-extensions",
+ "type": "github"
+ }
+ },
+ "nixago_2": {
+ "inputs": {
+ "flake-utils": "flake-utils_3",
+ "nixago-exts": "nixago-exts_2",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago",
+ "nixago-exts",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1676070010,
+ "narHash": "sha256-iYzJIWptE1EUD8VINAg66AAMUajizg8JUYN3oBmb8no=",
"owner": "nix-community",
"repo": "nixago",
- "rev": "1da60ad9412135f9ed7a004669fdcf3d378ec630",
+ "rev": "d480ba6c0c16e2c5c0bd2122852d6a0c9ad1ed0e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "ref": "rename-config-data",
+ "repo": "nixago",
+ "type": "github"
+ }
+ },
+ "nixago_3": {
+ "inputs": {
+ "flake-utils": "flake-utils_5",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago",
+ "nixago-exts",
+ "nixago",
+ "nixago-exts",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1655405483,
+ "narHash": "sha256-Crd49aZWNrpczlRTOwWGfwBMsTUoG9vlHDKQC7cx264=",
+ "owner": "nix-community",
+ "repo": "nixago",
+ "rev": "e6a9566c18063db5b120e69e048d3627414e327d",
"type": "github"
},
"original": {
@@ -253,284 +328,88 @@
"type": "github"
}
},
- "nixlib": {
+ "nixago_4": {
+ "inputs": {
+ "flake-utils": "flake-utils_7",
+ "nixago-exts": "nixago-exts_4",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago-exts",
+ "nixpkgs"
+ ]
+ },
"locked": {
- "lastModified": 1681001314,
- "narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=",
+ "lastModified": 1676070010,
+ "narHash": "sha256-iYzJIWptE1EUD8VINAg66AAMUajizg8JUYN3oBmb8no=",
"owner": "nix-community",
- "repo": "nixpkgs.lib",
- "rev": "367c0e1086a4eb4502b24d872cea2c7acdd557f4",
+ "repo": "nixago",
+ "rev": "d480ba6c0c16e2c5c0bd2122852d6a0c9ad1ed0e",
"type": "github"
},
"original": {
"owner": "nix-community",
- "repo": "nixpkgs.lib",
+ "ref": "rename-config-data",
+ "repo": "nixago",
+ "type": "github"
+ }
+ },
+ "nixago_5": {
+ "inputs": {
+ "flake-utils": "flake-utils_9",
+ "nixpkgs": [
+ "mfgames-project-setup",
+ "nixago-exts",
+ "nixago",
+ "nixago-exts",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1655405483,
+ "narHash": "sha256-Crd49aZWNrpczlRTOwWGfwBMsTUoG9vlHDKQC7cx264=",
+ "owner": "nix-community",
+ "repo": "nixago",
+ "rev": "e6a9566c18063db5b120e69e048d3627414e327d",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixago",
"type": "github"
}
},
"nixpkgs": {
"locked": {
- "lastModified": 1693565476,
- "narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=",
- "owner": "NixOS",
- "repo": "nixpkgs",
- "rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b",
- "type": "github"
+ "lastModified": 1706098335,
+ "narHash": "sha256-r3dWjT8P9/Ah5m5ul4WqIWD8muj5F+/gbCdjiNVBKmU=",
+ "rev": "a77ab169a83a4175169d78684ddd2e54486ac651",
+ "revCount": 554858,
+ "type": "tarball",
+ "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.554858%2Brev-a77ab169a83a4175169d78684ddd2e54486ac651/018d46f0-798f-71dc-a8c5-4689c46f7d12/source.tar.gz"
},
"original": {
- "id": "nixpkgs",
- "ref": "nixos-unstable",
- "type": "indirect"
+ "type": "tarball",
+ "url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
}
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1677063315,
- "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=",
- "owner": "nixos",
- "repo": "nixpkgs",
- "rev": "988cc958c57ce4350ec248d2d53087777f9e1949",
- "type": "github"
+ "lastModified": 1709569716,
+ "narHash": "sha256-iOR44RU4jQ+YPGrn+uQeYAp7Xo7Z/+gT+wXJoGxxLTY=",
+ "rev": "617579a787259b9a6419492eaac670a5f7663917",
+ "revCount": 556422,
+ "type": "tarball",
+ "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.556422%2Brev-617579a787259b9a6419492eaac670a5f7663917/018e0df2-b0f7-7a27-af1a-04150ef0f2c7/source.tar.gz"
},
"original": {
- "owner": "nixos",
- "ref": "nixos-unstable",
- "repo": "nixpkgs",
- "type": "github"
- }
- },
- "nosys": {
- "locked": {
- "lastModified": 1668010795,
- "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=",
- "owner": "divnix",
- "repo": "nosys",
- "rev": "feade0141487801c71ff55623b421ed535dbdefa",
- "type": "github"
- },
- "original": {
- "owner": "divnix",
- "repo": "nosys",
- "type": "github"
- }
- },
- "paisano": {
- "inputs": {
- "nixpkgs": [
- "std",
- "nixpkgs"
- ],
- "nosys": "nosys",
- "yants": [
- "std",
- "yants"
- ]
- },
- "locked": {
- "lastModified": 1686862844,
- "narHash": "sha256-m8l/HpRBJnZ3c0F1u0IyQ3nYGWE0R9V5kfORuqZPzgk=",
- "owner": "paisano-nix",
- "repo": "core",
- "rev": "6674b3d3577212c1eeecd30d62d52edbd000e726",
- "type": "github"
- },
- "original": {
- "owner": "paisano-nix",
- "ref": "0.1.1",
- "repo": "core",
- "type": "github"
- }
- },
- "paisano-actions": {
- "inputs": {
- "nixpkgs": [
- "std",
- "paisano-mdbook-preprocessor",
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1677306424,
- "narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=",
- "owner": "paisano-nix",
- "repo": "actions",
- "rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b",
- "type": "github"
- },
- "original": {
- "owner": "paisano-nix",
- "repo": "actions",
- "type": "github"
- }
- },
- "paisano-mdbook-preprocessor": {
- "inputs": {
- "crane": "crane",
- "fenix": "fenix",
- "nixpkgs": [
- "std",
- "nixpkgs"
- ],
- "paisano-actions": "paisano-actions",
- "std": [
- "std"
- ]
- },
- "locked": {
- "lastModified": 1680654400,
- "narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=",
- "owner": "paisano-nix",
- "repo": "mdbook-paisano-preprocessor",
- "rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1",
- "type": "github"
- },
- "original": {
- "owner": "paisano-nix",
- "repo": "mdbook-paisano-preprocessor",
- "type": "github"
- }
- },
- "paisano-tui": {
- "inputs": {
- "nixpkgs": [
- "std",
- "blank"
- ],
- "std": [
- "std"
- ]
- },
- "locked": {
- "lastModified": 1681847764,
- "narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=",
- "owner": "paisano-nix",
- "repo": "tui",
- "rev": "3096bad91cae73ab8ab3367d31f8a143d248a244",
- "type": "github"
- },
- "original": {
- "owner": "paisano-nix",
- "ref": "0.1.1",
- "repo": "tui",
- "type": "github"
+ "type": "tarball",
+ "url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
}
},
"root": {
"inputs": {
- "nixpkgs": "nixpkgs",
- "std": "std"
- }
- },
- "rust-analyzer-src": {
- "flake": false,
- "locked": {
- "lastModified": 1677221702,
- "narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=",
- "owner": "rust-lang",
- "repo": "rust-analyzer",
- "rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b",
- "type": "github"
- },
- "original": {
- "owner": "rust-lang",
- "ref": "nightly",
- "repo": "rust-analyzer",
- "type": "github"
- }
- },
- "rust-overlay": {
- "inputs": {
- "flake-utils": [
- "std",
- "paisano-mdbook-preprocessor",
- "crane",
- "flake-utils"
- ],
- "nixpkgs": [
- "std",
- "paisano-mdbook-preprocessor",
- "crane",
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1675391458,
- "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=",
- "owner": "oxalica",
- "repo": "rust-overlay",
- "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf",
- "type": "github"
- },
- "original": {
- "owner": "oxalica",
- "repo": "rust-overlay",
- "type": "github"
- }
- },
- "std": {
- "inputs": {
- "arion": [
- "std",
- "blank"
- ],
- "blank": "blank",
- "devshell": "devshell",
- "dmerge": "dmerge",
- "flake-utils": "flake-utils",
- "incl": "incl",
- "makes": [
- "std",
- "blank"
- ],
- "microvm": [
- "std",
- "blank"
- ],
- "n2c": "n2c",
- "nixago": "nixago",
- "nixpkgs": [
- "nixpkgs"
- ],
- "paisano": "paisano",
- "paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor",
- "paisano-tui": "paisano-tui",
- "yants": "yants"
- },
- "locked": {
- "lastModified": 1686877329,
- "narHash": "sha256-A/SU8KqlLP2MBuhi9wmt6gDhXyp+chCeDZ4OBxfSWBI=",
- "owner": "divnix",
- "repo": "std",
- "rev": "aa6d423b82b7b7c2a4545693dea9ed1db14676e7",
- "type": "github"
- },
- "original": {
- "owner": "divnix",
- "ref": "v0.23.2",
- "repo": "std",
- "type": "github"
- }
- },
- "yants": {
- "inputs": {
- "nixpkgs": [
- "std",
- "dmerge",
- "nixlib"
- ]
- },
- "locked": {
- "lastModified": 1686863218,
- "narHash": "sha256-kooxYm3/3ornWtVBNHM3Zh020gACUyFX2G0VQXnB+mk=",
- "owner": "divnix",
- "repo": "yants",
- "rev": "8f0da0dba57149676aa4817ec0c880fbde7a648d",
- "type": "github"
- },
- "original": {
- "owner": "divnix",
- "repo": "yants",
- "type": "github"
+ "mfgames-project-setup": "mfgames-project-setup",
+ "nixpkgs": "nixpkgs_2"
}
}
},
diff --git a/flake.nix b/flake.nix
index 5b47c7e..82da4fd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,26 +1,52 @@
{
- description = "A variety of .NET core libraries used for development";
-
inputs = {
- std.url = "github:divnix/std/v0.23.2";
- std.inputs.nixpkgs.follows = "nixpkgs";
- nixpkgs.url = "nixpkgs/nixos-unstable";
+ nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
+ mfgames-project-setup.url = "git+https://src.mfgames.com/nixos-contrib/mfgames-project-setup-flake.git";
};
- outputs = inputs @ {
- self,
- std,
- ...
- }:
- std.growOn {
- inherit inputs;
- systems = ["x86_64-linux"];
- cellsFrom = ./nix;
- cellBlocks = with std.blockTypes; [
- (devshells "shells")
- (nixago "configs")
- ];
- } {
- devShells = std.harvest self ["common" "shells"];
+ outputs = inputs @ { self, nixpkgs, mfgames-project-setup, ... }:
+ let
+ # Helpers for producing system-specific outputs
+ supportedSystems = [ "x86_64-linux" ];
+ forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
+ inherit system;
+ pkgs = import nixpkgs { inherit system; };
+ });
+ in
+ rec
+ {
+ # Set up the developer shell.
+ devShells = forEachSupportedSystem ({ system, pkgs }:
+ let
+ project-config = mfgames-project-setup.lib.mkConfig {
+ inherit system pkgs;
+ contributorCovenant.enable = true;
+ contributorCovenant.contact = "contact@mfgames.com";
+ developerCertificateOfOrigin.enable = true;
+ dotnet.enable = true;
+ };
+ in
+ {
+ # Shell
+ default = pkgs.mkShell {
+ packages = [
+ pkgs.gnugrep
+ pkgs.gawk
+ pkgs.diffutils
+ pkgs.fd
+ pkgs.just
+ pkgs.lefthook
+ pkgs.jq
+ pkgs.dotnet-sdk
+ pkgs.git
+ ]
+ ++ project-config.packages;
+
+ shellHook = project-config.shellHook;
+ };
+ });
+
+ # Formatting for the Nix files
+ formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixpkgs-fmt);
};
}
diff --git a/nix/common/configs.nix b/nix/common/configs.nix
deleted file mode 100644
index 3da1bf9..0000000
--- a/nix/common/configs.nix
+++ /dev/null
@@ -1,262 +0,0 @@
-{
- inputs,
- cell,
-}: let
- inherit (inputs) nixpkgs;
- inherit (inputs.cells) std presets;
- l = nixpkgs.lib // builtins;
-in {
- conform = {
- data = {
- commit = {
- header = {length = 89;};
- conventional = {
- # Only allow these types of conventional commits (inspired by Angular)
- types = [
- "build"
- "chore"
- "ci"
- "docs"
- "feat"
- "fix"
- "perf"
- "refactor"
- "style"
- "test"
- ];
- };
- };
- };
- };
-
- editorconfig = {
- hook.mode = "copy"; # already useful before entering the devshell
- data = {
- root = true;
-
- "*" = {
- # Common
- end_of_line = "lf";
- insert_final_newline = true;
- trim_trailing_whitespace = true;
- charset = "utf-8";
- indent_style = "space";
- indent_size = 4;
- indent_brace_style = "K&R";
- max_line_length = 80;
- tab_width = 4;
- curly_bracket_next_line = true;
-
- # Microsoft .NET properties
- csharp_new_line_before_members_in_object_initializers = false;
- csharp_preferred_modifier_order = "public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion";
- csharp_space_after_cast = false;
- csharp_style_var_elsewhere = "false:hint";
- csharp_style_var_for_built_in_types = "false:hint";
- csharp_style_var_when_type_is_apparent = "true:hint";
- csharp_preserve_single_line_statements = false;
- csharp_preserve_single_line_blocks = true;
- dotnet_style_predefined_type_for_locals_parameters_members = "true:hint";
- dotnet_style_predefined_type_for_member_access = "true:hint";
- dotnet_style_qualification_for_event = "true:hint";
- dotnet_style_qualification_for_field = "true:hint";
- dotnet_style_qualification_for_method = "true:hint";
- dotnet_style_qualification_for_property = "true:hint";
- dotnet_style_require_accessibility_modifiers = "for_non_interface_members:hint";
-
- # ReSharper properties
- resharper_alignment_tab_fill_style = "optimal_fill";
- resharper_apply_on_completion = true;
- resharper_blank_lines_after_control_transfer_statements = 1;
- resharper_blank_lines_around_single_line_auto_property = 1;
- resharper_blank_lines_around_single_line_property = 1;
- resharper_blank_lines_before_single_line_comment = 1;
- resharper_blank_lines_between_using_groups = 1;
- resharper_braces_for_for = "required";
- resharper_braces_for_foreach = "required";
- resharper_braces_for_ifelse = "required";
- resharper_braces_for_while = "required";
- resharper_can_use_global_alias = false;
- resharper_csharp_blank_lines_around_single_line_field = 1;
- resharper_csharp_blank_lines_around_single_line_invocable = 1;
- resharper_csharp_indent_style = "tab";
- resharper_csharp_insert_final_newline = true;
- resharper_csharp_keep_blank_lines_in_code = 1;
- resharper_csharp_keep_blank_lines_in_declarations = 1;
- resharper_csharp_new_line_before_while = true;
- resharper_csharp_use_indent_from_vs = false;
- resharper_csharp_wrap_arguments_style = "chop_if_long";
- resharper_csharp_wrap_extends_list_style = "chop_if_long";
- resharper_csharp_wrap_parameters_style = "chop_if_long";
- resharper_css_insert_final_newline = false;
- resharper_enforce_line_ending_style = true;
- resharper_html_insert_final_newline = false;
- resharper_indent_nested_fixed_stmt = true;
- resharper_js_indent_style = "tab";
- resharper_js_insert_final_newline = true;
- resharper_js_keep_blank_lines_in_code = 1;
- resharper_js_stick_comment = false;
- resharper_js_use_indent_from_vs = false;
- resharper_js_wrap_before_binary_opsign = true;
- resharper_js_wrap_chained_method_calls = "chop_if_long";
- resharper_keep_blank_lines_between_declarations = 1;
- resharper_min_blank_lines_after_imports = 1;
- resharper_place_attribute_on_same_line = false;
- resharper_place_constructor_initializer_on_same_line = false;
- resharper_place_type_constraints_on_same_line = false;
- resharper_protobuf_insert_final_newline = false;
- resharper_qualified_using_at_nested_scope = true;
- resharper_resx_insert_final_newline = false;
- resharper_space_within_single_line_array_initializer_braces = true;
- resharper_use_indents_from_main_language_in_file = false;
- resharper_vb_insert_final_newline = false;
- resharper_wrap_after_declaration_lpar = true;
- resharper_wrap_after_invocation_lpar = true;
- resharper_wrap_before_extends_colon = true;
- resharper_wrap_before_first_type_parameter_constraint = true;
- resharper_wrap_before_type_parameter_langle = true;
- resharper_xmldoc_indent_child_elements = "ZeroIndent";
- resharper_xmldoc_indent_text = "ZeroIndent";
- resharper_xmldoc_insert_final_newline = false;
- resharper_xml_insert_final_newline = false;
-
- # ReSharper inspection severities
- resharper_check_namespace_highlighting = "none";
- resharper_convert_to_auto_property_highlighting = "none";
- resharper_localizable_element_highlighting = "none";
- resharper_redundant_comma_in_attribute_list_highlighting = "none";
- resharper_redundant_comma_in_enum_declaration_highlighting = "none";
- resharper_redundant_comma_in_initializer_highlighting = "none";
- resharper_string_compare_to_is_culture_specific_highlighting = "none";
- resharper_string_index_of_is_culture_specific_1_highlighting = "none";
- resharper_use_null_propagation_highlighting = "none";
- resharper_use_object_or_collection_initializer_highlighting = "hint";
- resharper_use_string_interpolation_highlighting = "hint";
- };
-
- "*.{diff,patch}" = {
- end_of_line = "unset";
- insert_final_newline = "unset";
- trim_trailing_whitespace = "unset";
- indent_size = "unset";
- };
-
- "*.md" = {
- max_line_length = "off";
- trim_trailing_whitespace = false;
- };
-
- "package.json" = {
- indent_style = "space";
- indent_size = 2;
- tab_width = 2;
- };
-
- "*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}" = {
- indent_style = "space";
- indent_size = 2;
- tab_width = 2;
- };
-
- "{LICENSES/**,LICENSE}" = {
- end_of_line = "unset";
- insert_final_newline = "unset";
- trim_trailing_whitespace = "unset";
- charset = "unset";
- indent_style = "unset";
- indent_size = "unset";
- };
- };
- };
-
- lefthook = {
- data = {
- commit-msg = {
- commands = {
- # Runs conform on commit-msg hook to ensure commit messages are
- # compliant.
- conform = {
- run = "${nixpkgs.conform}/bin/conform enforce --commit-msg-file {1}";
- };
- };
- };
- pre-commit = {
- commands = {
- # Runs treefmt on pre-commit hook to ensure checked-in source code is
- # properly formatted.
- treefmt = {
- run = "${nixpkgs.treefmt}/bin/treefmt {staged_files}";
- };
- };
- };
- };
- };
-
- prettier = {
- data = {
- printWidth = 80;
- proseWrap = "always";
- };
- output = ".prettierrc";
- format = "json";
- };
-
- treefmt = {
- data = {
- formatter = {
- dotnet = {
- command = "dotnet";
- options = ["jb" "cleanupcode"];
- includes = ["*.cs"];
- };
-
- nix = {
- command = "alejandra";
- includes = ["*.nix" "*.nix.hbs"];
- };
-
- prettier = {
- command = "prettier";
- # 2023-09-02 DREM: Removed "--plugin" "prettier-plugin-toml"
- options = ["--write"];
- includes = [
- "*.css"
- "*.html"
- "*.js"
- "*.json"
- "*.jsx"
- "*.md"
- "*.mdx"
- "*.scss"
- "*.ts"
- "*.yaml"
- #"*.toml"
- ];
- };
-
- shell = {
- command = "shfmt";
- options = ["-i" "4" "-s" "-w"];
- includes = ["*.sh"];
- };
-
- # We mainly use it here to format the Markdown in our README.
- prettier = {
- excludes = ["**.min.js"];
- };
- };
- };
-
- packages = [
- nixpkgs.alejandra
- nixpkgs.nodePackages.prettier
- nixpkgs.nodePackages.prettier-plugin-toml
- nixpkgs.shfmt
- nixpkgs.go
- ];
-
- #devshell.startup.prettier-plugin-toml = l.stringsWithDeps.noDepEntry ''
- # export NODE_PATH=${nixpkgs.nodePackages.prettier-plugin-toml}/lib/node_modules:$NODE_PATH
- #'';
- };
-}
diff --git a/nix/common/shells.nix b/nix/common/shells.nix
deleted file mode 100644
index bea2b86..0000000
--- a/nix/common/shells.nix
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- inputs,
- cell,
-}: let
- inherit (inputs.std) std lib;
- inherit (inputs) nixpkgs;
- inherit (inputs.cells) cli;
-
- l = nixpkgs.lib // builtins;
-
- dev = lib.dev.mkShell {
- packages = [
- # Linux
- nixpkgs.gnugrep
- nixpkgs.gawk
- nixpkgs.diffutils
- nixpkgs.fd
-
- # Building
- nixpkgs.just
- nixpkgs.lefthook
- nixpkgs.jq
-
- # .NET
- nixpkgs.dotnet-sdk
-
- # Nix
- nixpkgs.nixfmt
- nixpkgs.alejandra
-
- # Git
- nixpkgs.git
- ];
-
- nixago = [
- (lib.cfg.conform cell.configs.conform)
- (lib.cfg.treefmt cell.configs.treefmt)
- (lib.cfg.editorconfig cell.configs.editorconfig)
- (lib.cfg.lefthook cell.configs.lefthook)
- ];
- };
-in {
- inherit dev;
- default = dev;
-}
diff --git a/src/MfGames.Crypto/ByteStringFormat.cs b/src/MfGames.Crypto/ByteStringFormat.cs
index cbe086a..10cdca7 100644
--- a/src/MfGames.Crypto/ByteStringFormat.cs
+++ b/src/MfGames.Crypto/ByteStringFormat.cs
@@ -2,18 +2,18 @@ namespace MfGames.Crypto;
public enum ByteStringFormat
{
- ///
- /// Indicates that the format should be lowercase hex characters.
- ///
- LowercaseHex,
+ ///
+ /// Indicates that the format should be lowercase hex characters.
+ ///
+ LowercaseHex,
- ///
- /// Indicates that the format should be uppercase hex characters.
- ///
- UppercaseHex,
+ ///
+ /// Indicates that the format should be uppercase hex characters.
+ ///
+ UppercaseHex,
- ///
- /// Indicates that the format should be Base64.
- ///
- Base64,
+ ///
+ /// Indicates that the format should be Base64.
+ ///
+ Base64,
}
diff --git a/src/MfGames.Crypto/Extensions/CryptoByteArrayExtensions.cs b/src/MfGames.Crypto/Extensions/CryptoByteArrayExtensions.cs
index 3605529..83bc5f4 100644
--- a/src/MfGames.Crypto/Extensions/CryptoByteArrayExtensions.cs
+++ b/src/MfGames.Crypto/Extensions/CryptoByteArrayExtensions.cs
@@ -7,67 +7,62 @@ namespace MfGames.Crypto.Extensions;
///
public static class CryptoByteArrayExtensions
{
- ///
- /// Converts the input into a hash string, such as hex or base64.
- ///
- ///
- ///
- ///
- public static string? ToByteString(
- this byte[]? input,
- ByteStringFormat format = ByteStringFormat.LowercaseHex)
- {
- if (input == null)
- {
- return null;
- }
+ ///
+ /// Converts the input into a hash string, such as hex or base64.
+ ///
+ ///
+ ///
+ ///
+ public static string? ToByteString(
+ this byte[]? input,
+ ByteStringFormat format = ByteStringFormat.LowercaseHex
+ )
+ {
+ if (input == null)
+ {
+ return null;
+ }
- switch (format)
- {
- case ByteStringFormat.LowercaseHex:
- return Convert.ToHexString(input).ToLowerInvariant();
+ switch (format)
+ {
+ case ByteStringFormat.LowercaseHex:
+ return Convert.ToHexString(input).ToLowerInvariant();
- case ByteStringFormat.UppercaseHex:
- return Convert.ToHexString(input);
+ case ByteStringFormat.UppercaseHex:
+ return Convert.ToHexString(input);
- case ByteStringFormat.Base64:
- return Convert.ToBase64String(input);
+ case ByteStringFormat.Base64:
+ return Convert.ToBase64String(input);
- default:
- throw new ArgumentOutOfRangeException(
- nameof(format),
- format,
- null);
- }
- }
+ default:
+ throw new ArgumentOutOfRangeException(nameof(format), format, null);
+ }
+ }
- ///
- /// Hashes the given input and returns the results.
- ///
- /// A byte array or null.
- /// The type of hash requested.
- /// Null if input is null, otherwise the hash value.
- public static byte[]? ToHashBytes(
- this byte[]? input,
- HashType hash = HashType.Sha512)
- {
- return input == null
- ? null
- : hash.CreateHash().ComputeHash(input);
- }
+ ///
+ /// Hashes the given input and returns the results.
+ ///
+ /// A byte array or null.
+ /// The type of hash requested.
+ /// Null if input is null, otherwise the hash value.
+ public static byte[]? ToHashBytes(this byte[]? input, HashType hash = HashType.Sha512)
+ {
+ return input == null ? null : hash.CreateHash().ComputeHash(input);
+ }
- ///
- /// Hashes the given input and returns the results as a string.
- ///
- /// A byte array or null.
- /// The type of hash requested.
- /// The format of the requested string.
- /// Null if input is null, otherwise the hash value.
- public static string? ToHashString(
- this byte[]? input,
- HashType hash = HashType.Sha512,
- ByteStringFormat format = ByteStringFormat.LowercaseHex)
- {
- return input?.ToHashBytes(hash)?.ToByteString(format);
- }
+ ///
+ /// Hashes the given input and returns the results as a string.
+ ///
+ /// A byte array or null.
+ /// The type of hash requested.
+ /// The format of the requested string.
+ /// Null if input is null, otherwise the hash value.
+ public static string? ToHashString(
+ this byte[]? input,
+ HashType hash = HashType.Sha512,
+ ByteStringFormat format = ByteStringFormat.LowercaseHex
+ )
+ {
+ return input?.ToHashBytes(hash)?.ToByteString(format);
+ }
}
diff --git a/src/MfGames.Crypto/Extensions/CryptoStringExtensions.cs b/src/MfGames.Crypto/Extensions/CryptoStringExtensions.cs
index 1d601e1..5862fbe 100644
--- a/src/MfGames.Crypto/Extensions/CryptoStringExtensions.cs
+++ b/src/MfGames.Crypto/Extensions/CryptoStringExtensions.cs
@@ -1,5 +1,4 @@
using System.Text;
-
using MfGames.Crypto.Hashes;
namespace MfGames.Crypto.Extensions;
@@ -9,54 +8,50 @@ namespace MfGames.Crypto.Extensions;
///
public static class CryptoStringExtensions
{
- ///
- /// Gets the encoded byte array of the given string.
- ///
- /// The input string or null.
- /// The encoding to use, defaults to UTF-8.
- /// Null if the input was null, otherwise the byte array.
- public static byte[]? ToBytes(
- this string? input,
- Encoding? encoding = null)
- {
- encoding ??= Encoding.UTF8;
+ ///
+ /// Gets the encoded byte array of the given string.
+ ///
+ /// The input string or null.
+ /// The encoding to use, defaults to UTF-8.
+ /// Null if the input was null, otherwise the byte array.
+ public static byte[]? ToBytes(this string? input, Encoding? encoding = null)
+ {
+ encoding ??= Encoding.UTF8;
- return input == null
- ? null
- : encoding.GetBytes(input);
- }
+ return input == null ? null : encoding.GetBytes(input);
+ }
- ///
- /// Hashes the given input and returns the results.
- ///
- /// A byte array or null.
- /// The type of hash requested.
- /// The encoding to use, defaults to UTF-8.
- /// Null if input is null, otherwise the hash value.
- public static byte[]? ToHashBytes(
- this string? input,
- HashType hash = HashType.Sha512,
- Encoding? encoding = null)
- {
- return input == null
- ? null
- : hash.CreateHash().ComputeHash(input.ToBytes(encoding)!);
- }
+ ///
+ /// Hashes the given input and returns the results.
+ ///
+ /// A byte array or null.
+ /// The type of hash requested.
+ /// The encoding to use, defaults to UTF-8.
+ /// Null if input is null, otherwise the hash value.
+ public static byte[]? ToHashBytes(
+ this string? input,
+ HashType hash = HashType.Sha512,
+ Encoding? encoding = null
+ )
+ {
+ return input == null ? null : hash.CreateHash().ComputeHash(input.ToBytes(encoding)!);
+ }
- ///
- /// Hashes the given input and returns the results as a string.
- ///
- /// A byte array or null.
- /// The type of hash requested.
- /// The format of the requested string.
- /// The encoding to use, defaults to UTF-8.
- /// Null if input is null, otherwise the hash value.
- public static string? ToHashString(
- this string? input,
- HashType hash = HashType.Sha512,
- ByteStringFormat format = ByteStringFormat.LowercaseHex,
- Encoding? encoding = null)
- {
- return input?.ToHashBytes(hash, encoding)?.ToByteString(format);
- }
+ ///
+ /// Hashes the given input and returns the results as a string.
+ ///
+ /// A byte array or null.
+ /// The type of hash requested.
+ /// The format of the requested string.
+ /// The encoding to use, defaults to UTF-8.
+ /// Null if input is null, otherwise the hash value.
+ public static string? ToHashString(
+ this string? input,
+ HashType hash = HashType.Sha512,
+ ByteStringFormat format = ByteStringFormat.LowercaseHex,
+ Encoding? encoding = null
+ )
+ {
+ return input?.ToHashBytes(hash, encoding)?.ToByteString(format);
+ }
}
diff --git a/src/MfGames.Crypto/Hashes/HashType.cs b/src/MfGames.Crypto/Hashes/HashType.cs
index fda0b79..67d237a 100644
--- a/src/MfGames.Crypto/Hashes/HashType.cs
+++ b/src/MfGames.Crypto/Hashes/HashType.cs
@@ -5,23 +5,23 @@ namespace MfGames.Crypto.Hashes;
///
public enum HashType
{
- ///
- /// Indicates a SHA-512 hash.
- ///
- Sha512,
+ ///
+ /// Indicates a SHA-512 hash.
+ ///
+ Sha512,
- ///
- /// Indicates a SHA-256 hash.
- ///
- Sha256,
+ ///
+ /// Indicates a SHA-256 hash.
+ ///
+ Sha256,
- ///
- /// Indicates a SHA-1 hash.
- ///
- Sha1,
+ ///
+ /// Indicates a SHA-1 hash.
+ ///
+ Sha1,
- ///
- /// Indicates a MD5 hash.
- ///
- Md5,
+ ///
+ /// Indicates a MD5 hash.
+ ///
+ Md5,
}
diff --git a/src/MfGames.Crypto/Hashes/HashTypeExtensions.cs b/src/MfGames.Crypto/Hashes/HashTypeExtensions.cs
index 81c692e..581a35d 100644
--- a/src/MfGames.Crypto/Hashes/HashTypeExtensions.cs
+++ b/src/MfGames.Crypto/Hashes/HashTypeExtensions.cs
@@ -4,30 +4,30 @@ namespace MfGames.Crypto.Hashes;
public static class HashTypeExtensions
{
- ///
- /// Constructs a hash of the given type.
- ///
- /// The type of hash to create.
- /// A hash algorithm of the given type.
- ///
- public static HashAlgorithm CreateHash(this HashType type)
- {
- switch (type)
- {
- case HashType.Sha512:
- return SHA512.Create();
+ ///
+ /// Constructs a hash of the given type.
+ ///
+ /// The type of hash to create.
+ /// A hash algorithm of the given type.
+ ///
+ public static HashAlgorithm CreateHash(this HashType type)
+ {
+ switch (type)
+ {
+ case HashType.Sha512:
+ return SHA512.Create();
- case HashType.Sha256:
- return SHA256.Create();
+ case HashType.Sha256:
+ return SHA256.Create();
- case HashType.Sha1:
- return SHA1.Create();
+ case HashType.Sha1:
+ return SHA1.Create();
- case HashType.Md5:
- return MD5.Create();
+ case HashType.Md5:
+ return MD5.Create();
- default:
- throw new ArgumentOutOfRangeException(nameof(type), type, null);
- }
- }
+ default:
+ throw new ArgumentOutOfRangeException(nameof(type), type, null);
+ }
+ }
}
diff --git a/src/MfGames.Gallium/Entity.cs b/src/MfGames.Gallium/Entity.cs
index c15bc9d..704f910 100644
--- a/src/MfGames.Gallium/Entity.cs
+++ b/src/MfGames.Gallium/Entity.cs
@@ -7,517 +7,497 @@ namespace MfGames.Gallium;
///
public record Entity
{
- public Entity()
- : this(Interlocked.Increment(ref nextId))
- {
- }
+ public Entity()
+ : this(Interlocked.Increment(ref nextId)) { }
- private Entity(int id)
- {
- this.Id = id;
- this.Components = ImmutableDictionary.Create();
- }
+ private Entity(int id)
+ {
+ this.Id = id;
+ this.Components = ImmutableDictionary.Create();
+ }
- ///
- /// Gets or sets the optional formatting for an entity. This is used to
- /// override the ToString functionality to provide additional information.
- /// If this is null, then the default "ToString" will be called.
- ///
- ///
- /// This must be a thread-safe function.
- ///
- public static Func? ToStringFormatter { get; set; }
+ ///
+ /// Gets or sets the optional formatting for an entity. This is used to
+ /// override the ToString functionality to provide additional information.
+ /// If this is null, then the default "ToString" will be called.
+ ///
+ ///
+ /// This must be a thread-safe function.
+ ///
+ public static Func? ToStringFormatter { get; set; }
- ///
- public virtual bool Equals(Entity? other)
- {
- if (ReferenceEquals(null, other))
- {
- return false;
- }
+ ///
+ public virtual bool Equals(Entity? other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
- if (ReferenceEquals(this, other))
- {
- return true;
- }
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
- return this.Id == other.Id;
- }
+ return this.Id == other.Id;
+ }
- ///
- public override int GetHashCode()
- {
- return this.Id.GetHashCode();
- }
+ ///
+ public override int GetHashCode()
+ {
+ return this.Id.GetHashCode();
+ }
- private ImmutableDictionary Components { get; init; }
+ private ImmutableDictionary Components { get; init; }
- ///
- /// The internal ID to ensure the entities are unique. Since we are not
- /// worried about serialization or using the identifiers from one call
- /// to another, we can use a simple interlocked identifier instead of
- /// a factory or provider method.
- ///
- private static int nextId;
+ ///
+ /// The internal ID to ensure the entities are unique. Since we are not
+ /// worried about serialization or using the identifiers from one call
+ /// to another, we can use a simple interlocked identifier instead of
+ /// a factory or provider method.
+ ///
+ private static int nextId;
- ///
- /// Gets a value indicating whether the entity has a specific type of
- /// component registered.
- ///
- /// The component type.
- /// True if the type exists, otherwise false.
- public bool Has()
- {
- return this.Has(typeof(T1));
- }
+ ///
+ /// Gets a value indicating whether the entity has a specific type of
+ /// component registered.
+ ///
+ /// The component type.
+ /// True if the type exists, otherwise false.
+ public bool Has()
+ {
+ return this.Has(typeof(T1));
+ }
- ///
- /// Gets a value indicating whether the entity has components of the given types
- /// registered.
- ///
- /// The first component type.
- /// The second component type.
- ///
- /// True if there are components of the given type exists, otherwise
- /// false.
- ///
- public bool HasAll()
- {
- return this.HasAll(typeof(T1), typeof(T2));
- }
+ ///
+ /// Gets a value indicating whether the entity has components of the given types
+ /// registered.
+ ///
+ /// The first component type.
+ /// The second component type.
+ ///
+ /// True if there are components of the given type exists, otherwise
+ /// false.
+ ///
+ public bool HasAll()
+ {
+ return this.HasAll(typeof(T1), typeof(T2));
+ }
- ///
- /// Gets a value indicating whether the entity has components of the given types
- /// registered.
- ///
- /// The first component type.
- /// The second component type.
- /// The third component type.
- ///
- /// True if there are components of the given type exists, otherwise
- /// false.
- ///
- public bool HasAll()
- {
- return this.HasAll(typeof(T1), typeof(T2), typeof(T3));
- }
+ ///
+ /// Gets a value indicating whether the entity has components of the given types
+ /// registered.
+ ///
+ /// The first component type.
+ /// The second component type.
+ /// The third component type.
+ ///
+ /// True if there are components of the given type exists, otherwise
+ /// false.
+ ///
+ public bool HasAll()
+ {
+ return this.HasAll(typeof(T1), typeof(T2), typeof(T3));
+ }
- ///
- /// Gets a value indicating whether the entity has components of the given types
- /// registered.
- ///
- /// The first component type.
- /// The second component type.
- /// The third component type.
- /// The third component type.
- ///
- /// True if there are components of the given type exists, otherwise
- /// false.
- ///
- public bool HasAll()
- {
- return this.HasAll(typeof(T1), typeof(T2), typeof(T3), typeof(T4));
- }
+ ///
+ /// Gets a value indicating whether the entity has components of the given types
+ /// registered.
+ ///
+ /// The first component type.
+ /// The second component type.
+ /// The third component type.
+ /// The third component type.
+ ///
+ /// True if there are components of the given type exists, otherwise
+ /// false.
+ ///
+ public bool HasAll()
+ {
+ return this.HasAll(typeof(T1), typeof(T2), typeof(T3), typeof(T4));
+ }
- ///
- /// Gets a value indicating whether the entity has a specific type of
- /// component registered.
- ///
- /// The component type.
- /// True if the type exists, otherwise false.
- public bool Has(Type type)
- {
- return this.Components.ContainsKey(type);
- }
+ ///
+ /// Gets a value indicating whether the entity has a specific type of
+ /// component registered.
+ ///
+ /// The component type.
+ /// True if the type exists, otherwise false.
+ public bool Has(Type type)
+ {
+ return this.Components.ContainsKey(type);
+ }
- ///
- /// Gets a value indicating whether the entity has components for all the given
- /// types.
- ///
- /// The component type.
- /// The component type.
- /// True if the type exists, otherwise false.
- public bool HasAll(
- Type t1,
- Type t2)
- {
- return this.Has(t1) && this.Components.ContainsKey(t2);
- }
+ ///
+ /// Gets a value indicating whether the entity has components for all the given
+ /// types.
+ ///
+ /// The component type.
+ /// The component type.
+ /// True if the type exists, otherwise false.
+ public bool HasAll(Type t1, Type t2)
+ {
+ return this.Has(t1) && this.Components.ContainsKey(t2);
+ }
- ///
- /// Gets a value indicating whether the entity has components for all the given
- /// types.
- ///
- /// The component type.
- /// The component type.
- /// The component type.
- /// True if the type exists, otherwise false.
- public bool HasAll(
- Type t1,
- Type t2,
- Type t3)
- {
- return this.HasAll(t1, t2) && this.Components.ContainsKey(t3);
- }
+ ///
+ /// Gets a value indicating whether the entity has components for all the given
+ /// types.
+ ///
+ /// The component type.
+ /// The component type.
+ /// The component type.
+ /// True if the type exists, otherwise false.
+ public bool HasAll(Type t1, Type t2, Type t3)
+ {
+ return this.HasAll(t1, t2) && this.Components.ContainsKey(t3);
+ }
- ///
- /// Gets a value indicating whether the entity has components for all the given
- /// types.
- ///
- /// The component type.
- /// The component type.
- /// The component type.
- /// The component type.
- /// True if the type exists, otherwise false.
- public bool HasAll(
- Type t1,
- Type t2,
- Type t3,
- Type t4)
- {
- return this.HasAll(t1, t2, t3) && this.Components.ContainsKey(t4);
- }
+ ///
+ /// Gets a value indicating whether the entity has components for all the given
+ /// types.
+ ///
+ /// The component type.
+ /// The component type.
+ /// The component type.
+ /// The component type.
+ /// True if the type exists, otherwise false.
+ public bool HasAll(Type t1, Type t2, Type t3, Type t4)
+ {
+ return this.HasAll(t1, t2, t3) && this.Components.ContainsKey(t4);
+ }
- ///
- /// Retrieves a registered component of the given type.
- ///
- /// The component type.
- /// The registered object.
- public TType Get()
- {
- return (TType)this.Components[typeof(TType)];
- }
+ ///
+ /// Retrieves a registered component of the given type.
+ ///
+ /// The component type.
+ /// The registered object.
+ public TType Get()
+ {
+ return (TType)this.Components[typeof(TType)];
+ }
- ///
- /// Retrieves a registered component of the given type and casts it to
- /// TType.
- ///
- /// The component key.
- /// The component type.
- /// The registered object.
- public TType Get(Type type)
- {
- return (TType)this.Components[type];
- }
+ ///
+ /// Retrieves a registered component of the given type and casts it to
+ /// TType.
+ ///
+ /// The component key.
+ /// The component type.
+ /// The registered object.
+ public TType Get(Type type)
+ {
+ return (TType)this.Components[type];
+ }
- ///
- /// Gets the number of components registered in the entity.
- ///
- public int Count => this.Components.Count;
+ ///
+ /// Gets the number of components registered in the entity.
+ ///
+ public int Count => this.Components.Count;
- ///
- /// Gets the given component type if inside the entity, otherwise the
- /// default value.
- ///
- /// The component type.
- /// The found component or default (typically null).
- public TType? GetOptional()
- {
- return this.Has() ? this.Get() : default;
- }
+ ///
+ /// Gets the given component type if inside the entity, otherwise the
+ /// default value.
+ ///
+ /// The component type.
+ /// The found component or default (typically null).
+ public TType? GetOptional()
+ {
+ return this.Has() ? this.Get() : default;
+ }
- ///
- /// Attempts to get the value, if present. If not, this returns false
- /// and the value is undefined. Otherwise, this method returns true
- /// and the actual value inside that variable.
- ///
- /// The value if contained in the entity.
- /// The component type.
- /// True if found, otherwise false.
- public bool TryGet(out T1 value)
- {
- if (this.Has())
- {
- value = this.Get();
+ ///
+ /// Attempts to get the value, if present. If not, this returns false
+ /// and the value is undefined. Otherwise, this method returns true
+ /// and the actual value inside that variable.
+ ///
+ /// The value if contained in the entity.
+ /// The component type.
+ /// True if found, otherwise false.
+ public bool TryGet(out T1 value)
+ {
+ if (this.Has())
+ {
+ value = this.Get();
- return true;
- }
+ return true;
+ }
- value = default!;
+ value = default!;
- return false;
- }
+ return false;
+ }
- ///
- /// Attempts to get the values, if present. If not, this returns false
- /// and the value is undefined. Otherwise, this method returns true
- /// and the actual value inside that variable.
- ///
- /// The value if contained in the entity.
- /// The value if contained in the entity.
- /// The first component type.
- /// The second component type.
- /// True if found, otherwise false.
- public bool TryGet(
- out T1 value1,
- out T2 value2)
- {
- if (this.HasAll())
- {
- value1 = this.Get();
- value2 = this.Get();
+ ///
+ /// Attempts to get the values, if present. If not, this returns false
+ /// and the value is undefined. Otherwise, this method returns true
+ /// and the actual value inside that variable.
+ ///
+ /// The value if contained in the entity.
+ /// The value if contained in the entity.
+ /// The first component type.
+ /// The second component type.
+ /// True if found, otherwise false.
+ public bool TryGet(out T1 value1, out T2 value2)
+ {
+ if (this.HasAll())
+ {
+ value1 = this.Get();
+ value2 = this.Get();
- return true;
- }
+ return true;
+ }
- value1 = default!;
- value2 = default!;
+ value1 = default!;
+ value2 = default!;
- return false;
- }
+ return false;
+ }
- ///
- /// Attempts to get the values, if present. If not, this returns false
- /// and the value is undefined. Otherwise, this method returns true
- /// and the actual value inside that variable.
- ///
- /// The value if contained in the entity.
- /// The value if contained in the entity.
- /// The value if contained in the entity.
- /// The first component type.
- /// The second component type.
- /// The third component type.
- /// True if found, otherwise false.
- public bool TryGet(
- out T1 value1,
- out T2 value2,
- out T3 value3)
- {
- if (this.HasAll())
- {
- value1 = this.Get();
- value2 = this.Get();
- value3 = this.Get();
+ ///
+ /// Attempts to get the values, if present. If not, this returns false
+ /// and the value is undefined. Otherwise, this method returns true
+ /// and the actual value inside that variable.
+ ///
+ /// The value if contained in the entity.
+ /// The value if contained in the entity.
+ /// The value if contained in the entity.
+ /// The first component type.
+ /// The second component type.
+ /// The third component type.
+ /// True if found, otherwise false.
+ public bool TryGet(out T1 value1, out T2 value2, out T3 value3)
+ {
+ if (this.HasAll())
+ {
+ value1 = this.Get();
+ value2 = this.Get();
+ value3 = this.Get();
- return true;
- }
+ return true;
+ }
- value1 = default!;
- value2 = default!;
- value3 = default!;
+ value1 = default!;
+ value2 = default!;
+ value3 = default!;
- return false;
- }
+ return false;
+ }
- ///
- /// Attempts to get the values, if present. If not, this returns false
- /// and the value is undefined. Otherwise, this method returns true
- /// and the actual value inside that variable.
- ///
- /// The value if contained in the entity.
- /// The value if contained in the entity.
- /// The value if contained in the entity.
- /// The value if contained in the entity.
- /// The first component type.
- /// The second component type.
- /// The third component type.
- /// The fourth component type.
- /// True if found, otherwise false.
- public bool TryGet(
- out T1 value1,
- out T2 value2,
- out T3 value3,
- out T4 value4)
- {
- if (this.HasAll())
- {
- value1 = this.Get();
- value2 = this.Get();
- value3 = this.Get();
- value4 = this.Get();
+ ///
+ /// Attempts to get the values, if present. If not, this returns false
+ /// and the value is undefined. Otherwise, this method returns true
+ /// and the actual value inside that variable.
+ ///
+ /// The value if contained in the entity.
+ /// The value if contained in the entity.
+ /// The value if contained in the entity.
+ /// The value if contained in the entity.
+ /// The first component type.
+ /// The second component type.
+ /// The third component type.
+ /// The fourth component type.
+ /// True if found, otherwise false.
+ public bool TryGet(out T1 value1, out T2 value2, out T3 value3, out T4 value4)
+ {
+ if (this.HasAll())
+ {
+ value1 = this.Get();
+ value2 = this.Get();
+ value3 = this.Get();
+ value4 = this.Get();
- return true;
- }
+ return true;
+ }
- value1 = default!;
- value2 = default!;
- value3 = default!;
- value4 = default!;
+ value1 = default!;
+ value2 = default!;
+ value3 = default!;
+ value4 = default!;
- return false;
- }
+ return false;
+ }
- ///
- /// Sets the component in the entity, regardless if there was a
- /// component already registered.
- ///
- /// The component to register.
- /// The component type.
- /// The entity for chaining.
- ///
- public Entity Set(T1 component)
- {
- if (component == null)
- {
- throw new ArgumentNullException(nameof(component));
- }
+ ///
+ /// Sets the component in the entity, regardless if there was a
+ /// component already registered.
+ ///
+ /// The component to register.
+ /// The component type.
+ /// The entity for chaining.
+ ///
+ public Entity Set(T1 component)
+ {
+ if (component == null)
+ {
+ throw new ArgumentNullException(nameof(component));
+ }
- if (this.Components.TryGetValue(typeof(T1), out object? value)
- && value is T1
- && value.Equals(component))
- {
- return this;
- }
+ if (
+ this.Components.TryGetValue(typeof(T1), out object? value)
+ && value is T1
+ && value.Equals(component)
+ )
+ {
+ return this;
+ }
- return this with
- {
- Components = this.Components.SetItem(typeof(T1), component),
- };
- }
+ return this with
+ {
+ Components = this.Components.SetItem(typeof(T1), component),
+ };
+ }
- ///
- /// Sets zero or more components into an entity in a single call. This does
- /// not allow for specifying the data type; each item will be added with
- /// the result of `component.GetType()`.
- ///
- ///
- /// The components to add to the entity. Any null objects
- /// will be ignored.
- ///
- ///
- /// A new Entity with the modified component collection if there is at
- /// least one component to set, otherwise the same entity.
- ///
- public Entity SetAll(params object?[] components)
- {
- if (components.Length == 0)
- {
- return this;
- }
+ ///
+ /// Sets zero or more components into an entity in a single call. This does
+ /// not allow for specifying the data type; each item will be added with
+ /// the result of `component.GetType()`.
+ ///
+ ///
+ /// The components to add to the entity. Any null objects
+ /// will be ignored.
+ ///
+ ///
+ /// A new Entity with the modified component collection if there is at
+ /// least one component to set, otherwise the same entity.
+ ///
+ public Entity SetAll(params object?[] components)
+ {
+ if (components.Length == 0)
+ {
+ return this;
+ }
- ImmutableDictionary collection = this.Components;
+ ImmutableDictionary collection = this.Components;
- foreach (object? component in components)
- {
- if (component != null)
- {
- collection = collection.SetItem(component.GetType(), component);
- }
- }
+ foreach (object? component in components)
+ {
+ if (component != null)
+ {
+ collection = collection.SetItem(component.GetType(), component);
+ }
+ }
- return this with
- {
- Components = collection,
- };
- }
+ return this with
+ {
+ Components = collection,
+ };
+ }
- ///
- /// Adds a component to the entity.
- ///
- /// The component to register.
- /// The component type.
- ///
- /// The same entity if the component is already registered, otherwise a
- /// cloned entity with the new component.
- ///
- ///
- public Entity Add(T1 component)
- {
- if (component == null)
- {
- throw new ArgumentNullException(nameof(component));
- }
+ ///
+ /// Adds a component to the entity.
+ ///
+ /// The component to register.
+ /// The component type.
+ ///
+ /// The same entity if the component is already registered, otherwise a
+ /// cloned entity with the new component.
+ ///
+ ///
+ public Entity Add(T1 component)
+ {
+ if (component == null)
+ {
+ throw new ArgumentNullException(nameof(component));
+ }
- if (this.Has())
- {
- throw new ArgumentException(
- "An element with the same type ("
- + typeof(T1).FullName
- + ") already exists.",
- nameof(component));
- }
+ if (this.Has())
+ {
+ throw new ArgumentException(
+ "An element with the same type (" + typeof(T1).FullName + ") already exists.",
+ nameof(component)
+ );
+ }
- if (this.Components.TryGetValue(typeof(T1), out object? value)
- && value is T1
- && value.Equals(component))
- {
- return this;
- }
+ if (
+ this.Components.TryGetValue(typeof(T1), out object? value)
+ && value is T1
+ && value.Equals(component)
+ )
+ {
+ return this;
+ }
- return this with
- {
- Components = this.Components.Add(typeof(T1), component)
- };
- }
+ return this with
+ {
+ Components = this.Components.Add(typeof(T1), component)
+ };
+ }
- ///
- /// Removes a component to the entity.
- ///
- /// The component type.
- ///
- /// The same entity if the component is already removed, otherwise a
- /// cloned entity without the new component.
- ///
- ///
- public Entity Remove()
- {
- return this.Remove(typeof(TType));
- }
+ ///
+ /// Removes a component to the entity.
+ ///
+ /// The component type.
+ ///
+ /// The same entity if the component is already removed, otherwise a
+ /// cloned entity without the new component.
+ ///
+ ///
+ public Entity Remove()
+ {
+ return this.Remove(typeof(TType));
+ }
- ///
- /// Removes a component to the entity.
- ///
- ///
- /// The same entity if the component is already removed, otherwise a
- /// cloned entity without the new component.
- ///
- /// The component type to remove.
- public Entity Remove(Type type)
- {
- if (!this.Has(type))
- {
- return this;
- }
+ ///
+ /// Removes a component to the entity.
+ ///
+ ///
+ /// The same entity if the component is already removed, otherwise a
+ /// cloned entity without the new component.
+ ///
+ /// The component type to remove.
+ public Entity Remove(Type type)
+ {
+ if (!this.Has(type))
+ {
+ return this;
+ }
- return this with
- {
- Components = this.Components.Remove(type)
- };
- }
+ return this with
+ {
+ Components = this.Components.Remove(type)
+ };
+ }
- ///
- /// Gets the identifier of the entity. This should be treated as an
- /// opaque field.
- ///
- public int Id { get; private init; }
+ ///
+ /// Gets the identifier of the entity. This should be treated as an
+ /// opaque field.
+ ///
+ public int Id { get; private init; }
- ///
- /// Creates a copy of the entity, including copying the identifier.
- ///
- ///
- public Entity ExactCopy()
- {
- return this with { };
- }
+ ///
+ /// Creates a copy of the entity, including copying the identifier.
+ ///
+ ///
+ public Entity ExactCopy()
+ {
+ return this with { };
+ }
- ///
- /// Creates a copy of the entity, including components, but with a new
- /// identifier.
- ///
- ///
- public Entity Copy()
- {
- return this with
- {
- Id = Interlocked.Increment(ref nextId)
- };
- }
+ ///
+ /// Creates a copy of the entity, including components, but with a new
+ /// identifier.
+ ///
+ ///
+ public Entity Copy()
+ {
+ return this with { Id = Interlocked.Increment(ref nextId) };
+ }
- ///
- /// Retrieves a list of the component types currently registered in the
- /// Entity.
- ///
- /// An enumerable of the various component keys.
- public IEnumerable GetComponentTypes()
- {
- return this.Components.Keys;
- }
+ ///
+ /// Retrieves a list of the component types currently registered in the
+ /// Entity.
+ ///
+ /// An enumerable of the various component keys.
+ public IEnumerable GetComponentTypes()
+ {
+ return this.Components.Keys;
+ }
- ///
- public override string ToString()
- {
- return ToStringFormatter == null
- ? $"Entity {this.Id} (Components {this.Components.Count:N0})"
- : ToStringFormatter(this);
- }
+ ///
+ public override string ToString()
+ {
+ return ToStringFormatter == null
+ ? $"Entity {this.Id} (Components {this.Components.Count:N0})"
+ : ToStringFormatter(this);
+ }
}
diff --git a/src/MfGames.Gallium/JoinEntityExtensions.cs b/src/MfGames.Gallium/JoinEntityExtensions.cs
index 1053e41..ec4b25e 100644
--- a/src/MfGames.Gallium/JoinEntityExtensions.cs
+++ b/src/MfGames.Gallium/JoinEntityExtensions.cs
@@ -2,23 +2,24 @@ namespace MfGames.Gallium;
public static class JoinEntityExtensions
{
- ///
- /// Merges two sets of entities using the identifier to determine which
- /// entities are the same. The `merge` function takes both of the
- /// entities with the Entity from the `input` first and the one from
- /// `other` second. The returning entity is put into the collection. If
- /// an entity from the input is not found in other, then it is just
- /// passed on.
- ///
- /// The enumerable of entities to merge to.
- /// The collection of entities to merge from.
- /// The callback to merge the two.
- /// An sequence of entities, merged and unmerged.
- public static IEnumerable JoinEntity(
- this IEnumerable input,
- ICollection other,
- Func merge)
- {
- return input.Join(other, a => a.Id, a => a.Id, merge);
- }
+ ///
+ /// Merges two sets of entities using the identifier to determine which
+ /// entities are the same. The `merge` function takes both of the
+ /// entities with the Entity from the `input` first and the one from
+ /// `other` second. The returning entity is put into the collection. If
+ /// an entity from the input is not found in other, then it is just
+ /// passed on.
+ ///
+ /// The enumerable of entities to merge to.
+ /// The collection of entities to merge from.
+ /// The callback to merge the two.
+ /// An sequence of entities, merged and unmerged.
+ public static IEnumerable JoinEntity(
+ this IEnumerable input,
+ ICollection other,
+ Func merge
+ )
+ {
+ return input.Join(other, a => a.Id, a => a.Id, merge);
+ }
}
diff --git a/src/MfGames.Gallium/SelectComponentExtensions.cs b/src/MfGames.Gallium/SelectComponentExtensions.cs
index fcf3126..1c1323c 100644
--- a/src/MfGames.Gallium/SelectComponentExtensions.cs
+++ b/src/MfGames.Gallium/SelectComponentExtensions.cs
@@ -5,43 +5,40 @@ namespace MfGames.Gallium;
///
public static class SelectComponentExtensions
{
- ///
- /// Retrieves a component from an entity and return it. If the entity does not have
- /// the component, it will be
- /// filtered out.
- ///
- /// The entities to process.
- /// The component type being searched.
- /// A sequence of T1.
- public static IEnumerable SelectComponent(
- this IEnumerable entities)
- {
- foreach (Entity entity in entities)
- {
- if (entity.TryGet(out T1 v1))
- {
- yield return v1;
- }
- }
- }
+ ///
+ /// Retrieves a component from an entity and return it. If the entity does not have
+ /// the component, it will be
+ /// filtered out.
+ ///
+ /// The entities to process.
+ /// The component type being searched.
+ /// A sequence of T1.
+ public static IEnumerable SelectComponent(this IEnumerable entities)
+ {
+ foreach (Entity entity in entities)
+ {
+ if (entity.TryGet(out T1 v1))
+ {
+ yield return v1;
+ }
+ }
+ }
- ///
- /// Retrieves a component from an entity and return it. If the entity does not have
- /// the component, it will be filtered out.
- ///
- /// The entities to process.
- /// The component type being searched.
- /// A sequence of T1.
- public static IEnumerable