diff --git a/.editorconfig b/.editorconfig index 6199b4c..eb01a97 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,5 @@ +root = true + [*] charset = utf-8 end_of_line = lf @@ -7,24 +9,16 @@ indent_style = space indent_size = 4 # A property with the same name was updated with a value 2 in a section [{*.yaml,*.yml}] [{*.yaml,*.yml}] -indent_style = space indent_size = 2 # A property with the same name was updated with a value 4 in a section [*]; with a value 4 in a section [*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}] -dotnet_diagnostic.CA1047.severity = error [*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}] -indent_style = space -indent_size = 4 # A property with the same name was updated with a value 2 in a section [{*.yaml,*.yml}] tab_width = 4 -dotnet_style_operator_placement_when_wrapping = beginning_of_line + dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error -dotnet_style_prefer_auto_properties = true:warning dotnet_style_object_initializer = true:suggestion dotnet_style_collection_initializer = true:suggestion dotnet_style_prefer_simplified_boolean_expressions = true:suggestion -dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion -dotnet_style_prefer_conditional_expression_over_return = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_prefer_inferred_tuple_names = true:suggestion dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion @@ -35,13 +29,8 @@ dotnet_style_namespace_match_folder = true:suggestion dotnet_style_readonly_field = true:warning dotnet_style_predefined_type_for_locals_parameters_members = true:warning dotnet_style_predefined_type_for_member_access = true:warning -dotnet_style_require_accessibility_modifiers = always:error dotnet_style_allow_multiple_blank_lines_experimental = false:silent dotnet_style_allow_statement_immediately_after_block_experimental = false:silent -dotnet_code_quality_unused_parameters = all:warning -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent dotnet_style_qualification_for_field = false:silent dotnet_style_qualification_for_property = false:silent @@ -712,14 +701,16 @@ resharper_blank_lines_inside_region = 1 resharper_blank_lines_inside_type = 0 resharper_blank_line_after_pi = true resharper_braces_for_dowhile = required -resharper_braces_for_fixed = required +resharper_braces_for_fixed = required_for_multiline resharper_braces_for_for = required_for_multiline resharper_braces_for_foreach = required_for_multiline resharper_braces_for_ifelse = required_for_multiline -resharper_braces_for_lock = required -resharper_braces_for_using = required +resharper_braces_for_lock = required_for_multiline +resharper_braces_for_using = required_for_multiline resharper_braces_for_while = required_for_multiline resharper_braces_redundant = true +resharper_builtin_type_apply_to_native_integer = true +resharper_csharp_empty_block_style = together_same_line resharper_break_template_declaration = line_break resharper_can_use_global_alias = false resharper_configure_await_analysis_mode = disabled @@ -817,7 +808,7 @@ resharper_indent_typearg_angles = inside resharper_indent_typeparam_angles = inside resharper_indent_type_constraints = true resharper_indent_wrapped_function_names = false -resharper_instance_members_qualify_declared_in = base_class +resharper_instance_members_qualify_declared_in = resharper_int_align_assignments = false resharper_int_align_binary_expressions = false resharper_int_align_declaration_names = false @@ -918,7 +909,7 @@ resharper_place_simple_switch_expression_on_single_line = false resharper_place_type_attribute_on_same_line = false resharper_place_type_constraints_on_same_line = true resharper_prefer_explicit_discard_declaration = false -resharper_prefer_separate_deconstructed_variables_declaration = true +resharper_prefer_separate_deconstructed_variables_declaration = false resharper_preserve_spaces_inside_tags = pre,textarea resharper_qualified_using_at_nested_scope = false resharper_quote_style = doublequoted @@ -1069,6 +1060,7 @@ resharper_space_within_typeof_parentheses = false resharper_space_within_type_argument_angles = false resharper_space_within_type_parameter_angles = false resharper_space_within_type_parameter_parentheses = false +resharper_csharp_allow_alias = false resharper_special_else_if_treatment = true resharper_static_members_qualify_members = none resharper_static_members_qualify_with = declared_type @@ -1289,7 +1281,7 @@ resharper_convert_to_using_declaration_highlighting = suggestion resharper_convert_to_vb_auto_property_highlighting = suggestion resharper_convert_to_vb_auto_property_when_possible_highlighting = hint resharper_convert_to_vb_auto_property_with_private_setter_highlighting = hint -resharper_convert_type_check_pattern_to_null_check_highlighting = warning +resharper_convert_type_check_pattern_to_null_check_highlighting = none resharper_convert_type_check_to_null_check_highlighting = warning resharper_co_variant_array_conversion_highlighting = warning resharper_c_declaration_with_implicit_int_type_highlighting = warning @@ -1872,4 +1864,17 @@ resharper_virtual_member_never_overridden_local_highlighting = suggestion resharper_void_method_with_must_use_return_value_attribute_highlighting = warning resharper_with_expression_instead_of_initializer_highlighting = suggestion resharper_wrong_indent_size_highlighting = none -resharper_xunit_xunit_test_with_console_output_highlighting = warning \ No newline at end of file +resharper_xunit_xunit_test_with_console_output_highlighting = warning +resharper_arrange_constructor_or_destructor_body_highlighting = hint +resharper_arrange_local_function_body_highlighting = hint +resharper_arrange_method_or_operator_body_highlighting = hint +resharper_arrange_null_checking_pattern_highlighting = suggestion +resharper_enforce_do_while_statement_braces_highlighting = warning +resharper_enforce_fixed_statement_braces_highlighting = warning +resharper_enforce_foreach_statement_braces_highlighting = suggestion +resharper_enforce_for_statement_braces_highlighting = suggestion +resharper_enforce_if_statement_braces_highlighting = suggestion +resharper_enforce_lock_statement_braces_highlighting = warning +resharper_enforce_while_statement_braces_highlighting = suggestion +resharper_remove_redundant_braces_highlighting = hint +resharper_suggest_discard_declaration_var_style_highlighting = warning \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 671caa7..cee3795 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -53,7 +53,7 @@ jobs: - name: Set up .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.x' + dotnet-version: '9.x' # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c4fe7dc..a95cb82 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -22,8 +22,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 7.0.x 8.0.x + 9.0.x - name: Restore dependencies run: dotnet restore - name: Build @@ -46,8 +46,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 7.0.x 8.0.x + 9.0.x - name: Restore dependencies run: dotnet restore - name: Build @@ -70,8 +70,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 7.0.x 8.0.x + 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/publish_nightly.yml b/.github/workflows/publish_nightly.yml index 52168d7..d479437 100644 --- a/.github/workflows/publish_nightly.yml +++ b/.github/workflows/publish_nightly.yml @@ -16,8 +16,8 @@ jobs: uses: "actions/setup-dotnet@v4" with: dotnet-version: | - 7.0.x 8.0.x + 9.0.x - name: Build run: dotnet build -c Release diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 7647e78..d1bcc05 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -15,8 +15,8 @@ jobs: uses: "actions/setup-dotnet@v4" with: dotnet-version: | - 7.0.x 8.0.x + 9.0.x - name: Build run: dotnet build -c Release diff --git a/Directory.Build.props b/Directory.Build.props index 5504ed8..1e65a20 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,8 +2,8 @@ - net7.0;net8.0 - latest + net8.0;net9.0 + latest-Recommended latest enable enable @@ -11,7 +11,6 @@ True True True - 2.3.3 Kotz Copyright © Kotz 2022 https://github.com/Kaoticz/Kotz.Utilities @@ -23,11 +22,11 @@ Avatar.png - + False - + True diff --git a/Kotz.Collections/Kotz.Collections.csproj b/Kotz.Collections/Kotz.Collections.csproj index 6ff2e63..4c54ffb 100644 --- a/Kotz.Collections/Kotz.Collections.csproj +++ b/Kotz.Collections/Kotz.Collections.csproj @@ -2,6 +2,7 @@ Provides collection types for common tasks. + 3.0.0 diff --git a/Kotz.DependencyInjection/Abstractions/ServiceAttributeBase.cs b/Kotz.DependencyInjection/Abstractions/ServiceBaseAttribute.cs similarity index 97% rename from Kotz.DependencyInjection/Abstractions/ServiceAttributeBase.cs rename to Kotz.DependencyInjection/Abstractions/ServiceBaseAttribute.cs index 1a2fedd..00abaed 100644 --- a/Kotz.DependencyInjection/Abstractions/ServiceAttributeBase.cs +++ b/Kotz.DependencyInjection/Abstractions/ServiceBaseAttribute.cs @@ -12,7 +12,7 @@ namespace Kotz.DependencyInjection.Abstractions; /// don't forget to also apply this attribute to the derived class. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] -public abstract class ServiceAttributeBase : Attribute +public abstract class ServiceBaseAttribute : Attribute { private readonly Action _serviceRegister; @@ -36,7 +36,7 @@ public abstract class ServiceAttributeBase : Attribute /// services under the same interface, otherwise. /// /// Occurs when a value for is not implemented. - protected ServiceAttributeBase(ServiceLifetime lifespan, bool allowMultiple) + protected ServiceBaseAttribute(ServiceLifetime lifespan, bool allowMultiple) { Lifetime = lifespan; AllowMultiple = allowMultiple; @@ -121,7 +121,7 @@ private static (string, string) GetRegisteredServiceError(IServiceCollection ioc return (registeredConcreteType ?? registeredService.ServiceType.Name, registeredService.ServiceType.Name + - ((string.IsNullOrWhiteSpace(registeredConcreteType) || registeredService.ServiceType.Name.Equals(registeredConcreteType)) + ((string.IsNullOrWhiteSpace(registeredConcreteType) || registeredService.ServiceType.Name.Equals(registeredConcreteType, StringComparison.Ordinal)) ? string.Empty : ": " + registeredConcreteType)); } diff --git a/Kotz.DependencyInjection/Extensions/IServiceCollectionExt.cs b/Kotz.DependencyInjection/Extensions/IServiceCollectionExt.cs index 882de39..3e2211a 100644 --- a/Kotz.DependencyInjection/Extensions/IServiceCollectionExt.cs +++ b/Kotz.DependencyInjection/Extensions/IServiceCollectionExt.cs @@ -11,7 +11,7 @@ public static class IServiceCollectionExt { /// /// Registers all types in the current assembly that are marked with a - /// attribute to this service collection. + /// attribute to this service collection. /// /// This service collection. /// This service collection with the services registered in it. @@ -23,7 +23,7 @@ public static IServiceCollection RegisterServices(this IServiceCollection servic /// /// Registers all types in the specifyed that are marked - /// with a attribute to this service collection. + /// with a attribute to this service collection. /// /// This service collection. /// The assembly to get the types from. @@ -33,8 +33,8 @@ public static IServiceCollection RegisterServices(this IServiceCollection servic /// public static IServiceCollection RegisterServices(this IServiceCollection serviceCollection, Assembly assembly) { - var typesAndAttributes = assembly.GetConcreteTypesWithAttribute() - .Select(x => (Type: x, Attribute: x.GetCustomAttribute()!)); + var typesAndAttributes = assembly.GetConcreteTypesWithAttribute() + .Select(x => (Type: x, Attribute: x.GetCustomAttribute()!)); foreach (var (type, attribute) in typesAndAttributes) attribute.RegisterService(serviceCollection, type); diff --git a/Kotz.DependencyInjection/Kotz.DependencyInjection.csproj b/Kotz.DependencyInjection/Kotz.DependencyInjection.csproj index 920d6c7..d0589bf 100644 --- a/Kotz.DependencyInjection/Kotz.DependencyInjection.csproj +++ b/Kotz.DependencyInjection/Kotz.DependencyInjection.csproj @@ -2,6 +2,7 @@ Provides utility methods and attributes for "Microsoft.Extensions.DependencyInjection". + 3.0.0 @@ -11,12 +12,12 @@ - - + + - - + + diff --git a/Kotz.DependencyInjection/ServiceAttribute.cs b/Kotz.DependencyInjection/ServiceAttribute.cs index 21d9dcf..da185a3 100644 --- a/Kotz.DependencyInjection/ServiceAttribute.cs +++ b/Kotz.DependencyInjection/ServiceAttribute.cs @@ -7,7 +7,7 @@ namespace Kotz.DependencyInjection; /// This attribute marks the class or struct it is applied to for /// registration in the IoC container for dependency injection. /// -public sealed class ServiceAttribute : ServiceAttributeBase +public sealed class ServiceAttribute : ServiceBaseAttribute { /// /// Marks this class for registration in the IoC container for dependency injection. diff --git a/Kotz.DependencyInjection/ServiceAttributeGeneric.cs b/Kotz.DependencyInjection/ServiceAttributeGeneric.cs index 0a902f8..7001f2f 100644 --- a/Kotz.DependencyInjection/ServiceAttributeGeneric.cs +++ b/Kotz.DependencyInjection/ServiceAttributeGeneric.cs @@ -9,7 +9,7 @@ namespace Kotz.DependencyInjection; /// registration in the IoC container for dependency injection. /// /// The abstract type the service should be registered under. -public sealed class ServiceAttribute : ServiceAttributeBase +public sealed class ServiceAttribute : ServiceBaseAttribute { /// /// Defines the type this service should be registered as. diff --git a/Kotz.Events/Kotz.Events.csproj b/Kotz.Events/Kotz.Events.csproj index 5559525..7e620a1 100644 --- a/Kotz.Events/Kotz.Events.csproj +++ b/Kotz.Events/Kotz.Events.csproj @@ -2,6 +2,8 @@ Provides generic and async event handlers. + 3.0.0 + CA1711 diff --git a/Kotz.Extensions/ArrayExt.cs b/Kotz.Extensions/ArrayExt.cs index 35b4dff..adc5fce 100644 --- a/Kotz.Extensions/ArrayExt.cs +++ b/Kotz.Extensions/ArrayExt.cs @@ -8,7 +8,6 @@ namespace Kotz.Extensions; /// public static class ArrayExt { -#if NET8_0_OR_GREATER /// /// Performs an in-place shuffle of this array. /// @@ -23,7 +22,6 @@ public static T[] Shuffle(this T[] array, Random? random) return array; } -#endif /// /// Creates a new over the entirety of the specified . diff --git a/Kotz.Extensions/CharExt.cs b/Kotz.Extensions/CharExt.cs index 95e1ef8..8ef1a41 100644 --- a/Kotz.Extensions/CharExt.cs +++ b/Kotz.Extensions/CharExt.cs @@ -294,7 +294,7 @@ public static bool IsWhiteSpace(this char character) /// if the character is already lowercase or not alphabetic. /// public static char ToLower(this char character) - => char.ToLower(character); + => char.ToLower(character, CultureInfo.CurrentCulture); /// /// Converts the value of this character to its lowercase equivalent using the specified @@ -331,7 +331,7 @@ public static char ToLowerInvariant(this char character) /// if it's already uppercase, has no uppercase equivalent, or is not alphabetic. /// public static char ToUpper(this char character) - => char.ToUpper(character); + => char.ToUpper(character, CultureInfo.CurrentCulture); /// /// Converts the value of this character to its uppercase equivalent using the specified diff --git a/Kotz.Extensions/INumberExt.cs b/Kotz.Extensions/INumberExt.cs index 20b4dae..899ac8c 100644 --- a/Kotz.Extensions/INumberExt.cs +++ b/Kotz.Extensions/INumberExt.cs @@ -30,7 +30,7 @@ public static T FromDigits(this string number, int @base) where T : struct, I { if (!number.All(char.IsAsciiLetterOrDigit)) throw new ArgumentException("The string must contain ASCII letters or digits only.", nameof(number)); - + if (number.Any(x => (char.IsAsciiDigit(x)) ? x >= '0' + @base : (char.IsAsciiLetterUpper(x)) ? x >= 'A' + @base - 10 : x >= 'a' + @base - 10)) throw new ArgumentException($"The number '{number}' cannot be represented in base {@base}", nameof(@base)); @@ -174,7 +174,7 @@ private static Span ToTwosComplement(T number, int @base, Span bu { if (++buffer[index] != @base + '0') break; - + buffer[index] = '0'; } diff --git a/Kotz.Extensions/Kotz.Extensions.csproj b/Kotz.Extensions/Kotz.Extensions.csproj index e666ef2..a1d44f8 100644 --- a/Kotz.Extensions/Kotz.Extensions.csproj +++ b/Kotz.Extensions/Kotz.Extensions.csproj @@ -1,6 +1,7 @@ Provides extension methods for common tasks. + 3.0.0 diff --git a/Kotz.Extensions/ListExt.cs b/Kotz.Extensions/ListExt.cs index f9cc1a6..184c9b6 100644 --- a/Kotz.Extensions/ListExt.cs +++ b/Kotz.Extensions/ListExt.cs @@ -7,7 +7,6 @@ namespace Kotz.Extensions; /// public static class ListExt { -#if NET8_0_OR_GREATER /// /// Performs an in-place shuffle of this span. /// @@ -22,7 +21,6 @@ public static List Shuffle(this List list, Random? random) return list; } -#endif /// /// Gets a view over the data in a list. Items should not be diff --git a/Kotz.Extensions/README.md b/Kotz.Extensions/README.md index 269aa8d..7cb7a2a 100644 --- a/Kotz.Extensions/README.md +++ b/Kotz.Extensions/README.md @@ -92,19 +92,4 @@ Defines the following extension methods: - TrimEnd: Removes all trailing instances of a character from the current string builder. - TrimStart: Removes all leading instances of a character from the current string builder. - **Task Extensions** - - Executes the current task asynchronously and safely returns it. - -Defines the following types: - -- **KotzUtilities**: static class with a wide range of helper methods. - - AddPathToPATHEnvar: Adds a directory path to the PATH environment variable. - - HasWritePermissionAt: Checks if this application can write to the specified directory. - - ProgramExists: Checks if a program exists at the specified absolute path or the PATH environment variable. - - StartProcess: Starts the specified program in the background. - - TryCreate: Safely creates an object with the specified factory method. - - TryDeleteFSO: Safely deletes a file or directory. - - TryDeleteFile: Safely deletes a file. - - TryDeleteDirectory: Safely deletes a directory. - - TryMoveFSO: Safely moves a file or directory. - - TryMoveFile: Safely moves a file. - - TryMoveDirectory: Safely moves a directory. \ No newline at end of file + - Executes the current task asynchronously and safely returns it. \ No newline at end of file diff --git a/Kotz.Extensions/SpanExt.cs b/Kotz.Extensions/SpanExt.cs index ce04abf..6bcb48f 100644 --- a/Kotz.Extensions/SpanExt.cs +++ b/Kotz.Extensions/SpanExt.cs @@ -5,7 +5,6 @@ namespace Kotz.Extensions; /// public static class SpanExt { -#if NET8_0_OR_GREATER /// /// Performs an in-place shuffle of this span. /// @@ -20,7 +19,6 @@ public static Span Shuffle(this Span span, Random? random) return span; } -#endif /// /// Rotates a span from a starting position by the specified of indices. diff --git a/Kotz.ObjectPool/Kotz.ObjectPool.csproj b/Kotz.ObjectPool/Kotz.ObjectPool.csproj index 68e6d3c..a06bf50 100644 --- a/Kotz.ObjectPool/Kotz.ObjectPool.csproj +++ b/Kotz.ObjectPool/Kotz.ObjectPool.csproj @@ -2,6 +2,7 @@ Provides a wrapper for "Microsoft.Extensions.ObjectPool". + 3.0.0 @@ -11,12 +12,12 @@ - - + + - - + + \ No newline at end of file diff --git a/Kotz.Tests/DependencyInjection/Models/NotRegisteredService.cs b/Kotz.Tests/DependencyInjection/Models/NotRegisteredService.cs index ab29596..ff2b513 100644 --- a/Kotz.Tests/DependencyInjection/Models/NotRegisteredService.cs +++ b/Kotz.Tests/DependencyInjection/Models/NotRegisteredService.cs @@ -3,6 +3,6 @@ namespace Kotz.Tests.DependencyInjection.Models; /// -/// Represents a service that has not been registered with the attribute. +/// Represents a service that has not been registered with the attribute. /// internal sealed record NotRegisteredService(); \ No newline at end of file diff --git a/Kotz.Tests/DependencyInjection/Registration/AttributeRegistrationTests.cs b/Kotz.Tests/DependencyInjection/Registration/AttributeRegistrationTests.cs index 895b4c1..3295b6f 100644 --- a/Kotz.Tests/DependencyInjection/Registration/AttributeRegistrationTests.cs +++ b/Kotz.Tests/DependencyInjection/Registration/AttributeRegistrationTests.cs @@ -27,7 +27,7 @@ internal void ConcreteResolutionTest(Type serviceType) using var scope = _serviceProvider.CreateScope(); var service1 = scope.ServiceProvider.GetRequiredService(serviceType); var service2 = scope.ServiceProvider.GetRequiredService(serviceType); - var attribute = serviceType.GetCustomAttribute()!; + var attribute = serviceType.GetCustomAttribute()!; if (attribute.Lifetime is ServiceLifetime.Transient) Assert.False(ReferenceEquals(service1, service2)); @@ -41,7 +41,7 @@ internal void ConcreteResolutionTest(Type serviceType) [InlineData(typeof(EmptyInterfacedTransientService), typeof(IEmpty))] internal void AbstractResolutionTest(Type serviceType, Type abstractType) { - var attribute = serviceType.GetCustomAttribute()!; + var attribute = serviceType.GetCustomAttribute()!; var serviceCollection = new ServiceCollection() .RegisterServices() .RemoveAll(abstractType); diff --git a/Kotz.Tests/Extensions/FillTests.cs b/Kotz.Tests/Extensions/FillTests.cs index a23a147..4ca92e8 100644 --- a/Kotz.Tests/Extensions/FillTests.cs +++ b/Kotz.Tests/Extensions/FillTests.cs @@ -2,10 +2,12 @@ namespace Kotz.Tests.Extensions; public sealed partial class LinqExtTests { + private static readonly string[] _sourceArray = ["Some strings", "This should create 5 slots"]; + [Fact] internal void FillTest() { - var sample = new string[] { "Some strings", "This should create 5 slots" } + var sample = _sourceArray .Select(x => x.Split(' ')) .NestedFill(string.Empty); diff --git a/Kotz.Tests/Extensions/Utilities/HasWritePermissionAtTests.cs b/Kotz.Tests/Extensions/Utilities/HasWritePermissionAtTests.cs index 1639a7f..4a4f108 100644 --- a/Kotz.Tests/Extensions/Utilities/HasWritePermissionAtTests.cs +++ b/Kotz.Tests/Extensions/Utilities/HasWritePermissionAtTests.cs @@ -1,3 +1,5 @@ +using Kotz.Utilities; + namespace Kotz.Tests.Extensions.Utilities; public sealed class HasWritePermissionAtTests diff --git a/Kotz.Tests/Extensions/Utilities/ProgramExistsTests.cs b/Kotz.Tests/Extensions/Utilities/ProgramExistsTests.cs index 48f47ef..3b2a01c 100644 --- a/Kotz.Tests/Extensions/Utilities/ProgramExistsTests.cs +++ b/Kotz.Tests/Extensions/Utilities/ProgramExistsTests.cs @@ -1,3 +1,5 @@ +using Kotz.Utilities; + namespace Kotz.Tests.Extensions.Utilities; public sealed class ProgramExistsTests diff --git a/Kotz.Tests/Extensions/Utilities/StartProgramTests.cs b/Kotz.Tests/Extensions/Utilities/StartProgramTests.cs index 83abbed..527acfd 100644 --- a/Kotz.Tests/Extensions/Utilities/StartProgramTests.cs +++ b/Kotz.Tests/Extensions/Utilities/StartProgramTests.cs @@ -1,3 +1,4 @@ +using Kotz.Utilities; using System.ComponentModel; namespace Kotz.Tests.Extensions.Utilities; diff --git a/Kotz.Tests/Extensions/Utilities/TryCreateTests.cs b/Kotz.Tests/Extensions/Utilities/TryCreateTests.cs index 32804a9..73d994a 100644 --- a/Kotz.Tests/Extensions/Utilities/TryCreateTests.cs +++ b/Kotz.Tests/Extensions/Utilities/TryCreateTests.cs @@ -1,3 +1,4 @@ +using Kotz.Utilities; using System.Text; namespace Kotz.Tests.Extensions.Utilities; diff --git a/Kotz.Tests/Extensions/Utilities/TryDeleteDirectoryTests.cs b/Kotz.Tests/Extensions/Utilities/TryDeleteDirectoryTests.cs index 4a36d4d..3c1144f 100644 --- a/Kotz.Tests/Extensions/Utilities/TryDeleteDirectoryTests.cs +++ b/Kotz.Tests/Extensions/Utilities/TryDeleteDirectoryTests.cs @@ -1,3 +1,5 @@ +using Kotz.Utilities; + namespace Kotz.Tests.Extensions.Utilities; public sealed class TryDeleteDirectoryTests diff --git a/Kotz.Tests/Extensions/Utilities/TryDeleteFileTests.cs b/Kotz.Tests/Extensions/Utilities/TryDeleteFileTests.cs index 6057542..5a543c3 100644 --- a/Kotz.Tests/Extensions/Utilities/TryDeleteFileTests.cs +++ b/Kotz.Tests/Extensions/Utilities/TryDeleteFileTests.cs @@ -1,3 +1,5 @@ +using Kotz.Utilities; + namespace Kotz.Tests.Extensions.Utilities; public sealed class TryDeleteFileTests diff --git a/Kotz.Tests/Extensions/Utilities/TryMoveDirectoryTests.cs b/Kotz.Tests/Extensions/Utilities/TryMoveDirectoryTests.cs index 16d567f..5ce4f51 100644 --- a/Kotz.Tests/Extensions/Utilities/TryMoveDirectoryTests.cs +++ b/Kotz.Tests/Extensions/Utilities/TryMoveDirectoryTests.cs @@ -1,3 +1,5 @@ +using Kotz.Utilities; + namespace Kotz.Tests.Extensions.Utilities; public sealed class TryMoveDirectoryTests diff --git a/Kotz.Tests/Extensions/Utilities/TryMoveFileTests.cs b/Kotz.Tests/Extensions/Utilities/TryMoveFileTests.cs index 87ce36e..4d5b161 100644 --- a/Kotz.Tests/Extensions/Utilities/TryMoveFileTests.cs +++ b/Kotz.Tests/Extensions/Utilities/TryMoveFileTests.cs @@ -1,3 +1,5 @@ +using Kotz.Utilities; + namespace Kotz.Tests.Extensions.Utilities; public sealed class TryMoveFileTests diff --git a/Kotz.Tests/Kotz.Tests.csproj b/Kotz.Tests/Kotz.Tests.csproj index 68060a5..d9b79b6 100644 --- a/Kotz.Tests/Kotz.Tests.csproj +++ b/Kotz.Tests/Kotz.Tests.csproj @@ -3,29 +3,39 @@ False Unit tests False + xUnit1012;IDE0005 - + False - + True + + + + + + + - - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + + + + \ No newline at end of file diff --git a/Kotz.Utilities/Kotz.Utilities.csproj b/Kotz.Utilities/Kotz.Utilities.csproj index d50de30..bf3d389 100644 --- a/Kotz.Utilities/Kotz.Utilities.csproj +++ b/Kotz.Utilities/Kotz.Utilities.csproj @@ -1,7 +1,8 @@ - Provides utility types and methods for common tasks. This is a metapackage that includes all Kotz utility packages. + Provides utility methods for common tasks. + 3.0.0 @@ -11,12 +12,4 @@ - - - - - - - - \ No newline at end of file diff --git a/Kotz.Extensions/KotzUtilities.cs b/Kotz.Utilities/KotzUtilities.cs similarity index 99% rename from Kotz.Extensions/KotzUtilities.cs rename to Kotz.Utilities/KotzUtilities.cs index 60b1676..67a8b3e 100644 --- a/Kotz.Extensions/KotzUtilities.cs +++ b/Kotz.Utilities/KotzUtilities.cs @@ -2,7 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -namespace Kotz.Extensions; +namespace Kotz.Utilities; /// /// A collection of utility methods. diff --git a/README.md b/README.md index c664e2d..3d67876 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,16 @@ -[![.NET Unit Tests][.NET-Badge]][.NET-Url] -[![CodeQL][CodeQL-Badge]][CodeQL-Url] -[![CodeFactor][CodeFactor-Badge]][CodeFactor-Url] -[![NuGet Badge][Nuget-Badge]][Nuget-Url] -[![NuGet Nightly Badge][Nuget-Nightly-Badge]][Nuget-Url] - # Kotz.Utilities -General C# utilities commonly used on projects I work on. - -Currently contains: -- Kotz.Utilities (Metapackage that contains all Kotz packages) -- [![Kotz.Collections-NuGet Downloads][Kotz.Collections-Nuget-Downloads]][Kotz.Collections-Nuget-Url] [Kotz.Collections] -- [![Kotz.DependencyInjection-NuGet Downloads][Kotz.DependencyInjection-Nuget-Downloads]][Kotz.DependencyInjection-Nuget-Url] [Kotz.DependencyInjection] -- [![Kotz.Events-NuGet Downloads][Kotz.Events-Nuget-Downloads]][Kotz.Events-Nuget-Url] [Kotz.Events] -- [![Kotz.Extensions-NuGet Downloads][Kotz.Extensions-Nuget-Downloads]][Kotz.Extensions-Nuget-Url] [Kotz.Extensions] -- [![Kotz.ObjectPool-NuGet Downloads][Kotz.ObjectPool-Nuget-Downloads]][Kotz.ObjectPool-Nuget-Url] [Kotz.ObjectPool] - - -[Kotz.Collections]: ./Kotz.Collections/README.md -[Kotz.DependencyInjection]: ./Kotz.DependencyInjection/README.md -[Kotz.Events]: ./Kotz.Events/README.md -[Kotz.Extensions]: ./Kotz.Extensions/README.md -[Kotz.ObjectPool]: ./Kotz.ObjectPool/README.md -[CodeFactor-Url]: https://www.codefactor.io/repository/github/kaoticz/kotz.utilities/overview/main -[CodeFactor-Badge]: https://www.codefactor.io/repository/github/kaoticz/kotz.utilities/badge/main -[.NET-Url]: ../../actions/workflows/dotnet.yml -[.NET-Badge]: ../../actions/workflows/dotnet.yml/badge.svg -[CodeQL-Url]: ../../actions/workflows/codeql-analysis.yml -[CodeQL-Badge]: ../../actions/workflows/codeql-analysis.yml/badge.svg -[Nuget-Badge]: https://img.shields.io/nuget/v/Kotz.Utilities.svg?label=NuGet -[Nuget-Nightly-Badge]: https://img.shields.io/nuget/vpre/Kotz.Utilities?color=00007f&label=NuGet%20Nightly -[Nuget-Url]: https://www.nuget.org/packages/Kotz.Utilities +Defines the following types: -[Kotz.Collections-Nuget-Downloads]: https://img.shields.io/nuget/dt/Kotz.Collections?color=00aa00 -[Kotz.Collections-Nuget-Url]: https://www.nuget.org/packages/Kotz.Collections -[Kotz.Extensions-Nuget-Downloads]: https://img.shields.io/nuget/dt/Kotz.Extensions?color=00aa00 -[Kotz.Extensions-Nuget-Url]: https://www.nuget.org/packages/Kotz.Extensions -[Kotz.ObjectPool-Nuget-Downloads]: https://img.shields.io/nuget/dt/Kotz.ObjectPool?color=00aa00 -[Kotz.ObjectPool-Nuget-Url]: https://www.nuget.org/packages/Kotz.ObjectPool -[Kotz.Events-Nuget-Downloads]: https://img.shields.io/nuget/dt/Kotz.Events?color=00aa00 -[Kotz.Events-Nuget-Url]: https://www.nuget.org/packages/Kotz.Events -[Kotz.DependencyInjection-Nuget-Downloads]: https://img.shields.io/nuget/dt/Kotz.DependencyInjection?color=00aa00 -[Kotz.DependencyInjection-Nuget-Url]: https://www.nuget.org/packages/Kotz.DependencyInjection \ No newline at end of file +- **KotzUtilities**: static class with a wide range of helper methods. + - AddPathToPATHEnvar: Adds a directory path to the PATH environment variable. + - HasWritePermissionAt: Checks if this application can write to the specified directory. + - ProgramExists: Checks if a program exists at the specified absolute path or the PATH environment variable. + - StartProcess: Starts the specified program in the background. + - TryCreate: Safely creates an object with the specified factory method. + - TryDeleteFSO: Safely deletes a file or directory. + - TryDeleteFile: Safely deletes a file. + - TryDeleteDirectory: Safely deletes a directory. + - TryMoveFSO: Safely moves a file or directory. + - TryMoveFile: Safely moves a file. + - TryMoveDirectory: Safely moves a directory. \ No newline at end of file