diff --git a/Directory.Build.props b/Directory.Build.props index 0a3ab02..40a36e2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 3.10.0 + 3.11.0 diff --git a/Directory.Packages.props b/Directory.Packages.props index 3d10d63..7ad4c85 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,12 +4,13 @@ + + - diff --git a/JustArchiNET.Madness.sln.DotSettings b/JustArchiNET.Madness.sln.DotSettings index c99050e..f9d8c52 100644 --- a/JustArchiNET.Madness.sln.DotSettings +++ b/JustArchiNET.Madness.sln.DotSettings @@ -6,8 +6,7 @@ False True True - ExplicitlyExcluded - + SOLUTION True SUGGESTION @@ -33,6 +32,7 @@ SUGGESTION SUGGESTION SUGGESTION + SUGGESTION SUGGESTION SUGGESTION SUGGESTION @@ -197,12 +197,14 @@ SUGGESTION SUGGESTION + HINT WARNING SUGGESTION True SUGGESTION WARNING + WARNING SUGGESTION SUGGESTION SUGGESTION @@ -236,6 +238,7 @@ HINT SUGGESTION SUGGESTION + SUGGESTION WARNING WARNING WARNING @@ -250,6 +253,7 @@ SUGGESTION SUGGESTION SUGGESTION + WARNING SUGGESTION SUGGESTION WARNING @@ -261,6 +265,7 @@ SUGGESTION WARNING SUGGESTION + SUGGESTION SUGGESTION SUGGESTION SUGGESTION @@ -286,7 +291,12 @@ SUGGESTION SUGGESTION + SUGGESTION + SUGGESTION + SUGGESTION + SUGGESTION SUGGESTION + WARNING SUGGESTION SUGGESTION SUGGESTION @@ -295,15 +305,18 @@ SUGGESTION SUGGESTION SUGGESTION + SUGGESTION + WARNING SUGGESTION WARNING WARNING WARNING + True SUGGESTION Default Default Default - + <?xml version="1.0" encoding="utf-16"?><Profile name="Archi"><CSReorderTypeMembers>True</CSReorderTypeMembers><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><HtmlReformatCode>True</HtmlReformatCode><JsInsertSemicolon>True</JsInsertSemicolon><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><CorrectVariableKindsDescriptor>True</CorrectVariableKindsDescriptor><VariablesToInnerScopesDescriptor>True</VariablesToInnerScopesDescriptor><StringToTemplatesDescriptor>True</StringToTemplatesDescriptor><JsReformatCode>True</JsReformatCode><JsFormatDocComments>True</JsFormatDocComments><RemoveRedundantQualifiersTs>True</RemoveRedundantQualifiersTs><OptimizeImportsTs>True</OptimizeImportsTs><OptimizeReferenceCommentsTs>True</OptimizeReferenceCommentsTs><PublicModifierStyleTs>True</PublicModifierStyleTs><ExplicitAnyTs>True</ExplicitAnyTs><TypeAnnotationStyleTs>True</TypeAnnotationStyleTs><RelativePathStyleTs>True</RelativePathStyleTs><AsInsteadOfCastTs>True</AsInsteadOfCastTs><XMLReformatCode>True</XMLReformatCode><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" ArrangeVarStyle="True" ArrangeTrailingCommas="True" ArrangeObjectCreation="True" ArrangeDefaultValue="True" ArrangeNamespaces="True" /><RemoveCodeRedundanciesVB>True</RemoveCodeRedundanciesVB><CssAlphabetizeProperties>True</CssAlphabetizeProperties><VBOptimizeImports>True</VBOptimizeImports><VBShortenReferences>True</VBShortenReferences><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CssReformatCode>True</CssReformatCode><VBReformatCode>True</VBReformatCode><VBFormatDocComments>True</VBFormatDocComments><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSUpdateFileHeader>True</CSUpdateFileHeader><Xaml.RedundantFreezeAttribute>True</Xaml.RedundantFreezeAttribute><Xaml.RemoveRedundantModifiersAttribute>True</Xaml.RemoveRedundantModifiersAttribute><Xaml.RemoveRedundantNameAttribute>True</Xaml.RemoveRedundantNameAttribute><Xaml.RemoveRedundantResource>True</Xaml.RemoveRedundantResource><Xaml.RemoveRedundantCollectionProperty>True</Xaml.RemoveRedundantCollectionProperty><Xaml.RemoveRedundantAttachedPropertySetter>True</Xaml.RemoveRedundantAttachedPropertySetter><Xaml.RemoveRedundantStyledValue>True</Xaml.RemoveRedundantStyledValue><Xaml.RemoveRedundantNamespaceAlias>True</Xaml.RemoveRedundantNamespaceAlias><Xaml.RemoveForbiddenResourceName>True</Xaml.RemoveForbiddenResourceName><Xaml.RemoveRedundantGridDefinitionsAttribute>True</Xaml.RemoveRedundantGridDefinitionsAttribute><Xaml.RemoveRedundantGridSpanAttribut>True</Xaml.RemoveRedundantGridSpanAttribut><Xaml.RemoveRedundantUpdateSourceTriggerAttribute>True</Xaml.RemoveRedundantUpdateSourceTriggerAttribute><Xaml.RemoveRedundantBindingModeAttribute>True</Xaml.RemoveRedundantBindingModeAttribute><CppAddTypenameTemplateKeywords>True</CppAddTypenameTemplateKeywords><CppJoinDeclarationAndAssignmentDescriptor>True</CppJoinDeclarationAndAssignmentDescriptor><CppMakeLocalVarConstDescriptor>True</CppMakeLocalVarConstDescriptor><CppMakeMethodConst>True</CppMakeMethodConst><CppMakeMethodStatic>True</CppMakeMethodStatic><CppRemoveElseKeyword>True</CppRemoveElseKeyword><CppRemoveRedundantMemberInitializerDescriptor>True</CppRemoveRedundantMemberInitializerDescriptor><CppRemoveRedundantParentheses>True</CppRemoveRedundantParentheses><CppShortenQualifiedName>True</CppShortenQualifiedName><CppDeleteRedundantSpecifier>True</CppDeleteRedundantSpecifier><CppRemoveStatement>True</CppRemoveStatement><CppRemoveTemplateArgumentsDescriptor>True</CppRemoveTemplateArgumentsDescriptor><CppDeleteRedundantTypenameTemplateKeywords>True</CppDeleteRedundantTypenameTemplateKeywords><CppRemoveUnreachableCode>True</CppRemoveUnreachableCode><CppRemoveUnusedIncludes>True</CppRemoveUnusedIncludes><CppRemoveUnusedLambdaCaptures>True</CppRemoveUnusedLambdaCaptures><CppCStyleToStaticCastDescriptor>True</CppCStyleToStaticCastDescriptor><CppReplaceExpressionWithBooleanConst>True</CppReplaceExpressionWithBooleanConst><CppMakeIfConstexpr>True</CppMakeIfConstexpr><CppMakePostfixOperatorPrefix>True</CppMakePostfixOperatorPrefix><CppChangeSmartPointerToMakeFunction>True</CppChangeSmartPointerToMakeFunction><CppReplaceThrowWithRethrowFix>True</CppReplaceThrowWithRethrowFix><CppReplaceExpressionWithNullptr>True</CppReplaceExpressionWithNullptr><CppCodeStyleCleanupDescriptor ArrangeAuto="True" ArrangeBraces="True" ArrangeCVQualifiers="True" ArrangeFunctionDeclarations="True" ArrangeNestedNamespaces="True" ArrangeOverridingFunctions="True" ArrangeSlashesInIncludeDirectives="True" ArrangeTypeAliases="True" SortIncludeDirectives="True" SortMemberInitializers="True" /><CppReformatCode>True</CppReformatCode><CppUpdateFileHeader>True</CppUpdateFileHeader><IDEA_SETTINGS>&lt;profile version="1.0"&gt; &lt;option name="myName" value="Archi" /&gt; &lt;inspection_tool class="ConditionalExpressionWithIdenticalBranchesJS" enabled="true" level="WARNING" enabled_by_default="true" /&gt; @@ -312,7 +325,7 @@ &lt;inspection_tool class="JSRemoveUnnecessaryParentheses" enabled="true" level="WARNING" enabled_by_default="true" /&gt; &lt;inspection_tool class="TypeScriptExplicitMemberType" enabled="true" level="WARNING" enabled_by_default="true" /&gt; &lt;inspection_tool class="UnterminatedStatementJS" enabled="true" level="WARNING" enabled_by_default="true" /&gt; -&lt;/profile&gt;</IDEA_SETTINGS><CppRemoveCastDescriptor>True</CppRemoveCastDescriptor><CppRemoveElaboratedTypeSpecifierDescriptor>True</CppRemoveElaboratedTypeSpecifierDescriptor><CppRemoveRedundantLambdaParameterListDescriptor>True</CppRemoveRedundantLambdaParameterListDescriptor><CppTypeTraitAliasDescriptor>True</CppTypeTraitAliasDescriptor><CppReplaceTieWithStructuredBindingDescriptor>True</CppReplaceTieWithStructuredBindingDescriptor><CppUseAssociativeContainsDescriptor>True</CppUseAssociativeContainsDescriptor><CppUseEraseAlgorithmDescriptor>True</CppUseEraseAlgorithmDescriptor><RIDER_SETTINGS>&lt;profile&gt; +&lt;/profile&gt;</IDEA_SETTINGS><ShaderLabReformatCode>True</ShaderLabReformatCode><CppRemoveCastDescriptor>True</CppRemoveCastDescriptor><CppRemoveElaboratedTypeSpecifierDescriptor>True</CppRemoveElaboratedTypeSpecifierDescriptor><CppRemoveRedundantLambdaParameterListDescriptor>True</CppRemoveRedundantLambdaParameterListDescriptor><CppTypeTraitAliasDescriptor>True</CppTypeTraitAliasDescriptor><CppReplaceTieWithStructuredBindingDescriptor>True</CppReplaceTieWithStructuredBindingDescriptor><CppUseAssociativeContainsDescriptor>True</CppUseAssociativeContainsDescriptor><CppUseEraseAlgorithmDescriptor>True</CppUseEraseAlgorithmDescriptor><RIDER_SETTINGS>&lt;profile&gt; &lt;Language id="CSS"&gt; &lt;Rearrange&gt;true&lt;/Rearrange&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; @@ -365,7 +378,7 @@ &lt;Language id="yaml"&gt; &lt;Reformat&gt;true&lt;/Reformat&gt; &lt;/Language&gt; -&lt;/profile&gt;</RIDER_SETTINGS></Profile> +&lt;/profile&gt;</RIDER_SETTINGS><FSReformatCode>True</FSReformatCode><CppMakePtrOrRefParameterConst>True</CppMakePtrOrRefParameterConst><CppMakeParameterConst>True</CppMakeParameterConst><CppClangTidyCleanupDescriptor abseil-cleanup-ctad="True" abseil-duration-addition="True" abseil-duration-comparison="True" abseil-duration-conversion-cast="True" abseil-duration-division="True" abseil-duration-factory-float="True" abseil-duration-factory-scale="True" abseil-duration-subtraction="True" abseil-duration-unnecessary-conversion="True" abseil-faster-strsplit-delimiter="True" abseil-redundant-strcat-calls="True" abseil-str-cat-append="True" abseil-string-find-startswith="True" abseil-string-find-str-contains="True" abseil-time-comparison="True" abseil-time-subtraction="True" abseil-upgrade-duration-conversions="True" android-cloexec-accept="True" android-cloexec-creat="True" android-cloexec-dup="True" android-cloexec-epoll-create="True" android-cloexec-epoll-create1="True" android-cloexec-fopen="True" android-cloexec-inotify-init="True" android-cloexec-inotify-init1="True" android-cloexec-memfd-create="True" android-cloexec-open="True" android-cloexec-pipe="True" boost-use-to-string="True" bugprone-argument-comment="True" bugprone-bool-pointer-implicit-conversion="True" bugprone-copy-constructor-init="True" bugprone-implicit-widening-of-multiplication-result="True" bugprone-inaccurate-erase="True" bugprone-macro-parentheses="True" bugprone-misplaced-operator-in-strlen-in-alloc="True" bugprone-misplaced-pointer-arithmetic-in-alloc="True" bugprone-move-forwarding-reference="True" bugprone-not-null-terminated-result="True" bugprone-parent-virtual-call="True" bugprone-posix-return="True" bugprone-redundant-branch-condition="True" bugprone-reserved-identifier="True" bugprone-shared-ptr-array-mismatch="True" bugprone-string-constructor="True" bugprone-string-integer-assignment="True" bugprone-stringview-nullptr="True" bugprone-suspicious-memset-usage="True" bugprone-suspicious-semicolon="True" bugprone-suspicious-string-compare="True" bugprone-swapped-arguments="True" bugprone-terminating-continue="True" bugprone-unused-raii="True" bugprone-virtual-near-miss="True" cert-dcl03-c="True" cert-dcl16-c="True" cert-dcl21-cpp="True" cert-oop11-cpp="True" cppcoreguidelines-explicit-virtual-functions="True" cppcoreguidelines-init-variables="True" cppcoreguidelines-prefer-member-initializer="True" cppcoreguidelines-pro-bounds-constant-array-index="True" cppcoreguidelines-pro-type-cstyle-cast="True" cppcoreguidelines-pro-type-member-init="True" cppcoreguidelines-pro-type-static-cast-downcast="True" cppcoreguidelines-virtual-class-destructor="True" darwin-dispatch-once-nonstatic="True" fuchsia-default-arguments-declarations="True" fuchsia-restrict-system-includes="True" google-build-explicit-make-pair="True" google-explicit-constructor="True" google-objc-avoid-nsobject-new="True" google-objc-function-naming="True" google-readability-braces-around-statements="True" google-readability-casting="True" google-readability-redundant-smartptr-get="True" google-readability-todo="True" google-upgrade-googletest-case="True" hicpp-braces-around-statements="True" hicpp-deprecated-headers="True" hicpp-explicit-conversions="True" hicpp-member-init="True" hicpp-move-const-arg="True" hicpp-named-parameter="True" hicpp-static-assert="True" hicpp-uppercase-literal-suffix="True" hicpp-use-auto="True" hicpp-use-emplace="True" hicpp-use-equals-default="True" hicpp-use-equals-delete="True" hicpp-use-noexcept="True" hicpp-use-nullptr="True" hicpp-use-override="True" llvm-else-after-return="True" llvm-header-guard="True" llvm-include-order="True" llvm-prefer-isa-or-dyn-cast-in-conditionals="True" llvm-prefer-register-over-unsigned="True" llvm-qualified-auto="True" llvm-twine-local="True" llvmlibc-restrict-system-libc-headers="True" misc-const-correctness="True" misc-definitions-in-headers="True" misc-macro-parentheses="True" misc-redundant-expression="True" misc-static-assert="True" misc-string-compare="True" misc-string-integer-assignment="True" misc-suspicious-string-compare="True" misc-uniqueptr-reset-release="True" misc-unused-alias-decls="True" misc-unused-parameters="True" misc-unused-raii="True" misc-unused-using-decls="True" modernize-avoid-bind="True" modernize-concat-nested-namespaces="True" modernize-deprecated-headers="True" modernize-deprecated-ios-base-aliases="True" modernize-loop-convert="True" modernize-macro-to-enum="True" modernize-make-shared="True" modernize-make-unique="True" modernize-pass-by-value="True" modernize-raw-string-literal="True" modernize-redundant-void-arg="True" modernize-replace-auto-ptr="True" modernize-replace-disallow-copy-and-assign-macro="True" modernize-replace-random-shuffle="True" modernize-return-braced-init-list="True" modernize-shrink-to-fit="True" modernize-use-auto="True" modernize-use-bool-literals="True" modernize-use-default-member-init="True" modernize-use-emplace="True" modernize-use-equals-default="True" modernize-use-equals-delete="True" modernize-use-nodiscard="True" modernize-use-noexcept="True" modernize-use-nullptr="True" modernize-use-override="True" modernize-use-trailing-return-type="True" modernize-use-uncaught-exceptions="True" modernize-use-using="True" objc-assert-equals="True" objc-property-declaration="True" objc-super-self="True" performance-faster-string-find="True" performance-for-range-copy="True" performance-inefficient-algorithm="True" performance-inefficient-vector-operation="True" performance-move-const-arg="True" performance-move-constructor-init="True" performance-noexcept-move-constructor="True" performance-trivially-destructible="True" performance-type-promotion-in-math-fn="True" performance-unnecessary-value-param="True" portability-restrict-system-includes="True" readability-braces-around-statements="True" readability-const-return-type="True" readability-container-contains="True" readability-container-data-pointer="True" readability-container-size-empty="True" readability-convert-member-functions-to-static="True" readability-delete-null-pointer="True" readability-duplicate-include="True" readability-else-after-return="True" readability-identifier-naming="True" readability-implicit-bool-conversion="True" readability-inconsistent-declaration-parameter-name="True" readability-isolate-declaration="True" readability-make-member-function-const="True" readability-misplaced-array-index="True" readability-named-parameter="True" readability-non-const-parameter="True" readability-qualified-auto="True" readability-redundant-access-specifiers="True" readability-redundant-control-flow="True" readability-redundant-declaration="True" readability-redundant-function-ptr-dereference="True" readability-redundant-member-init="True" readability-redundant-smartptr-get="True" readability-redundant-string-cstr="True" readability-redundant-string-init="True" readability-simplify-boolean-expr="True" readability-simplify-subscript-expr="True" readability-static-accessed-through-instance="True" readability-static-definition-in-anonymous-namespace="True" readability-string-compare="True" readability-uniqueptr-delete-release="True" readability-uppercase-literal-suffix="True" other-fixits="True" /></Profile> Archi USE_TABS_ONLY True @@ -378,13 +391,14 @@ ExpressionBody ExpressionBody public protected internal private static extern new virtual abstract sealed override readonly unsafe volatile async - + Arithmetic, Shift, Bitwise, Conditional END_OF_LINE END_OF_LINE USE_TABS_ONLY False - + False + END_OF_LINE 1 1 @@ -397,6 +411,7 @@ 0 END_OF_LINE TOGETHER_SAME_LINE + NO_INDENT Tab END_OF_LINE END_OF_LINE @@ -407,11 +422,12 @@ False True False - + True 1 END_OF_LINE + True NEVER NEVER False @@ -426,6 +442,7 @@ True True + False END_OF_LINE False True @@ -695,8 +712,33 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + AES + API + ASF BSD + EWCF + FA + FS + GC + GID + HTML + IASF + ID + IP + IPC + OK OS + PICS + PIN + SC + SMS + TTL + URL + WCF + WS + WTF + WWW + XML False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="I" Suffix="" Style="AaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> @@ -728,7 +770,7 @@ limitations under the License. LIVE_MONITOR NOTIFY NOTIFY - + True NOTIFY diff --git a/JustArchiNET.Madness/DirectoryInfoMadness/DirectoryInfo.cs b/JustArchiNET.Madness/DirectoryInfoMadness/DirectoryInfo.cs new file mode 100644 index 0000000..16541f3 --- /dev/null +++ b/JustArchiNET.Madness/DirectoryInfoMadness/DirectoryInfo.cs @@ -0,0 +1,50 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.IO; +using System.Security.AccessControl; +using JetBrains.Annotations; +using JustArchiNET.Madness.ArgumentNullExceptionMadness; +using JustArchiNET.Madness.FileMadness; +using JustArchiNET.Madness.Helpers; +using JustArchiNET.Madness.Internal; + +namespace JustArchiNET.Madness.DirectoryInfoMadness; + +[MadnessType(EMadnessType.Replacement)] +[PublicAPI] +public sealed class DirectoryInfo { + private readonly System.IO.DirectoryInfo UnderlyingDirectoryInfo; + + [MadnessType(EMadnessType.Implementation)] + public UnixFileMode UnixFileMode { + get => UnixFileMode.None; + set => NativeMethods.Chmod(UnderlyingDirectoryInfo.FullName, value); + } + + [MadnessType(EMadnessType.Proxy)] + public DirectoryInfo(string path) : this(new System.IO.DirectoryInfo(path)) { } + + internal DirectoryInfo(System.IO.DirectoryInfo directoryInfo) => UnderlyingDirectoryInfo = directoryInfo ?? throw new ArgumentNullException(nameof(directoryInfo)); + + [MadnessType(EMadnessType.Proxy)] + public void SetAccessControl(DirectorySecurity directorySecurity) => UnderlyingDirectoryInfo.SetAccessControl(directorySecurity); +} diff --git a/JustArchiNET.Madness/DirectoryMadness/Directory.cs b/JustArchiNET.Madness/DirectoryMadness/Directory.cs new file mode 100644 index 0000000..ef10dda --- /dev/null +++ b/JustArchiNET.Madness/DirectoryMadness/Directory.cs @@ -0,0 +1,66 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using System.IO; +using JetBrains.Annotations; +using JustArchiNET.Madness.Helpers; +using DirectoryInfo = JustArchiNET.Madness.DirectoryInfoMadness.DirectoryInfo; + +namespace JustArchiNET.Madness.DirectoryMadness; + +[MadnessType(EMadnessType.Replacement)] +[PublicAPI] +public static class Directory { + [MadnessType(EMadnessType.Replacement)] + public static DirectoryInfo CreateDirectory(string path) { + System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(path); + + return new DirectoryInfo(directoryInfo); + } + + [MadnessType(EMadnessType.Proxy)] + public static void Delete(string path) => System.IO.Directory.Delete(path); + + [MadnessType(EMadnessType.Proxy)] + public static void Delete(string path, bool recursive) => System.IO.Directory.Delete(path, recursive); + + [MadnessType(EMadnessType.Proxy)] + public static IEnumerable EnumerateDirectories(string path) => System.IO.Directory.EnumerateDirectories(path); + + [MadnessType(EMadnessType.Proxy)] + public static IEnumerable EnumerateFiles(string path, string searchPattern) => System.IO.Directory.EnumerateFiles(path, searchPattern); + + [MadnessType(EMadnessType.Proxy)] + public static IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption) => System.IO.Directory.EnumerateFiles(path, searchPattern, searchOption); + + [MadnessType(EMadnessType.Proxy)] + public static IEnumerable EnumerateFileSystemEntries(string path) => System.IO.Directory.EnumerateFileSystemEntries(path); + + [MadnessType(EMadnessType.Proxy)] + public static bool Exists(string path) => System.IO.Directory.Exists(path); + + [MadnessType(EMadnessType.Proxy)] + public static string GetCurrentDirectory() => System.IO.Directory.GetCurrentDirectory(); + + [MadnessType(EMadnessType.Proxy)] + public static void SetCurrentDirectory(string path) => System.IO.Directory.SetCurrentDirectory(path); +} diff --git a/JustArchiNET.Madness/FileInfoMadness/FileInfo.cs b/JustArchiNET.Madness/FileInfoMadness/FileInfo.cs new file mode 100644 index 0000000..cb804d8 --- /dev/null +++ b/JustArchiNET.Madness/FileInfoMadness/FileInfo.cs @@ -0,0 +1,50 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.IO; +using System.Security.AccessControl; +using JetBrains.Annotations; +using JustArchiNET.Madness.ArgumentNullExceptionMadness; +using JustArchiNET.Madness.FileMadness; +using JustArchiNET.Madness.Helpers; +using JustArchiNET.Madness.Internal; + +namespace JustArchiNET.Madness.FileInfoMadness; + +[MadnessType(EMadnessType.Replacement)] +[PublicAPI] +public sealed class FileInfo { + private readonly System.IO.FileInfo UnderlyingFileInfo; + + [MadnessType(EMadnessType.Implementation)] + public UnixFileMode UnixFileMode { + get => UnixFileMode.None; + set => NativeMethods.Chmod(UnderlyingFileInfo.FullName, value); + } + + [MadnessType(EMadnessType.Proxy)] + public FileInfo(string path) : this(new System.IO.FileInfo(path)) { } + + internal FileInfo(System.IO.FileInfo fileInfo) => UnderlyingFileInfo = fileInfo ?? throw new ArgumentNullException(nameof(fileInfo)); + + [MadnessType(EMadnessType.Proxy)] + public void SetAccessControl(FileSecurity fileSecurity) => UnderlyingFileInfo.SetAccessControl(fileSecurity); +} diff --git a/JustArchiNET.Madness/FileMadness/UnixFileMode.cs b/JustArchiNET.Madness/FileMadness/UnixFileMode.cs new file mode 100644 index 0000000..7efc20d --- /dev/null +++ b/JustArchiNET.Madness/FileMadness/UnixFileMode.cs @@ -0,0 +1,45 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Diagnostics.CodeAnalysis; +using JetBrains.Annotations; +using JustArchiNET.Madness.Helpers; + +namespace JustArchiNET.Madness.FileMadness; + +[MadnessType(EMadnessType.Implementation)] +[PublicAPI] +[SuppressMessage("ReSharper", "InconsistentNaming")] +public enum UnixFileMode { + None = 0, + OtherExecute = 1, + OtherWrite = 2, + OtherRead = 4, + GroupExecute = 8, + GroupWrite = 16, + GroupRead = 32, + UserExecute = 64, + UserWrite = 128, + UserRead = 256, + StickyBit = 512, + SetGroup = 1024, + SetUser = 2048 +} diff --git a/JustArchiNET.Madness/Internal/NativeMethods.cs b/JustArchiNET.Madness/Internal/NativeMethods.cs new file mode 100644 index 0000000..3f768c5 --- /dev/null +++ b/JustArchiNET.Madness/Internal/NativeMethods.cs @@ -0,0 +1,30 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Runtime.InteropServices; +using JustArchiNET.Madness.FileMadness; + +namespace JustArchiNET.Madness.Internal; + +internal static class NativeMethods { + [DllImport("libc", EntryPoint = "chmod", SetLastError = true)] + internal static extern int Chmod(string path, UnixFileMode mode); +} diff --git a/JustArchiNET.Madness/JustArchiNET.Madness.csproj b/JustArchiNET.Madness/JustArchiNET.Madness.csproj index dd1ffbc..6650a3b 100644 --- a/JustArchiNET.Madness/JustArchiNET.Madness.csproj +++ b/JustArchiNET.Madness/JustArchiNET.Madness.csproj @@ -12,12 +12,13 @@ + + - diff --git a/JustArchiNET.Madness/NewtonsoftJsonMadness/JsonTextReader.cs b/JustArchiNET.Madness/NewtonsoftJsonMadness/JsonTextReader.cs new file mode 100644 index 0000000..52ae829 --- /dev/null +++ b/JustArchiNET.Madness/NewtonsoftJsonMadness/JsonTextReader.cs @@ -0,0 +1,40 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.IO; +using System.Threading.Tasks; +using JetBrains.Annotations; +using JustArchiNET.Madness.Helpers; + +namespace JustArchiNET.Madness.NewtonsoftJsonMadness; + +[MadnessType(EMadnessType.Replacement)] +[PublicAPI] +public class JsonTextReader : Newtonsoft.Json.JsonTextReader, IAsyncDisposable { + public JsonTextReader(TextReader reader) : base(reader) { } + + public ValueTask DisposeAsync() { + Dispose(true); + + return default(ValueTask); + } +} diff --git a/JustArchiNET.Madness/NewtonsoftJsonMadness/JsonTextWriter.cs b/JustArchiNET.Madness/NewtonsoftJsonMadness/JsonTextWriter.cs new file mode 100644 index 0000000..ce09798 --- /dev/null +++ b/JustArchiNET.Madness/NewtonsoftJsonMadness/JsonTextWriter.cs @@ -0,0 +1,40 @@ +// _ __ __ +// ___ ___ ___ _ __ __| | __ _ | \/ | +// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| | +// \__ \\__ \| __/| | | || (_| || (_| || | | | +// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_| +// | +// Copyright 2021-2023 Łukasz "JustArchi" Domeradzki +// Contact: JustArchi@JustArchi.net +// | +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// | +// http://www.apache.org/licenses/LICENSE-2.0 +// | +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.IO; +using System.Threading.Tasks; +using JetBrains.Annotations; +using JustArchiNET.Madness.Helpers; + +namespace JustArchiNET.Madness.NewtonsoftJsonMadness; + +[MadnessType(EMadnessType.Replacement)] +[PublicAPI] +public class JsonTextWriter : Newtonsoft.Json.JsonTextWriter, IAsyncDisposable { + public JsonTextWriter(TextWriter writer) : base(writer) { } + + public ValueTask DisposeAsync() { + Dispose(true); + + return default(ValueTask); + } +} diff --git a/README.md b/README.md index bd4832a..50a4ba2 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,10 @@ We support `netstandard2.0`, so .NET Framework 4.6.1 and newer. There is also a dotnet add package JustArchiNET.Madness ``` -If you're targetting multiple frameworks out of which only one is .NET Framework (e.g. `net5.0` and `net48`), it's *usually* a good idea to not pull it for the others. +If you're targetting multiple frameworks out of which only one is .NET Framework (e.g. `net7.0` and `net481`), it's *usually* a good idea to not pull it for the others. ```csproj - + ``` @@ -57,19 +57,25 @@ Instead of adding `using` clause to each file, you can instead decide to do it o Example: ```csproj - + + + + + + + @@ -82,7 +88,7 @@ Example: We recommend to add `` clauses only for parts that you actually require/want to use from Madness. -Because of the `File` using declared above, you're now able to write this very nice ifdef-free code for both `net48` and newer platform target: +Because of the `File` using declared above, you're now able to write this very nice ifdef-free code for both `net481` and newer platform target: ```csharp using System.IO; @@ -260,7 +266,7 @@ namespace ThisIsMadness { If you're building only for .NET Framework exclusively, no, it's not required and actually quite useless code verbosity for you. -However, if you're targetting multiple frameworks out of which only one is .NET Framework (e.g. `net5.0` and `net48`), then `#if` clause guarantees that madness won't embrace your other targets. +However, if you're targetting multiple frameworks out of which only one is .NET Framework (e.g. `net7.0` and `net481`), then `#if` clause guarantees that madness won't embrace your other targets. You don't want madness to embrace your other targets, do you?