diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..d81987e --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '39 4 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # 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) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..f19799c --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,29 @@ +name: .NET + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + + runs-on: windows-latest + strategy: + fail-fast: false + env: + SOLUTION: "./source/Appccelerate.IO.sln" + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + - name: Restore dependencies + run: dotnet restore $env:SOLUTION + - name: Build + run: dotnet build $env:SOLUTION --no-restore + - name: Test + run: dotnet test $env:SOLUTION --no-build --verbosity normal diff --git a/README.md b/README.md index 339fef5..476c0fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Appccelrate.IO +# Appccelrate.IO -Simplifies interaction with the file system. +Simplifies interaction with the file system on Windows. Other operating systems than Windows are not supported. -Documentation at http://www.appccelerate.com/io.html +Documentation at [appccelerate.github.io/io](http://appccelerate.github.io/io.html) diff --git a/source/Analyzers.Facts.ruleset b/source/Analyzers.Facts.ruleset new file mode 100644 index 0000000..b17a65a --- /dev/null +++ b/source/Analyzers.Facts.ruleset @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/Analyzers.Productive.ruleset b/source/Analyzers.Productive.ruleset new file mode 100644 index 0000000..040d8ee --- /dev/null +++ b/source/Analyzers.Productive.ruleset @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/Appccelerate.IO.Facts/AbsoluteFilePathFacts.cs b/source/Appccelerate.IO.Facts/AbsoluteFilePathFacts.cs index 1ec603f..360ec4c 100644 --- a/source/Appccelerate.IO.Facts/AbsoluteFilePathFacts.cs +++ b/source/Appccelerate.IO.Facts/AbsoluteFilePathFacts.cs @@ -58,7 +58,7 @@ public void ThrowsException_WhenPathIsAFolder() { Action action = () => new AbsoluteFilePath(FolderPath); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -66,7 +66,7 @@ public void ThrowsException_WhenPathIsNotAbsolute() { Action action = () => new AbsoluteFilePath(@".\file"); - action.ShouldThrow(); + action.Should().Throw(); } [Theory] diff --git a/source/Appccelerate.IO.Facts/AbsoluteFolderPathFacts.cs b/source/Appccelerate.IO.Facts/AbsoluteFolderPathFacts.cs index c1e138a..b9d4f08 100644 --- a/source/Appccelerate.IO.Facts/AbsoluteFolderPathFacts.cs +++ b/source/Appccelerate.IO.Facts/AbsoluteFolderPathFacts.cs @@ -60,7 +60,7 @@ public void ThrowsException_WhenPathIsNotAbsolute() { Action action = () => new AbsolutePath(@"..\folder\"); - action.ShouldThrow(); + action.Should().Throw(); } [Theory] diff --git a/source/Appccelerate.IO.Facts/AbsolutePathFacts.cs b/source/Appccelerate.IO.Facts/AbsolutePathFacts.cs index 9604ca6..c437d2b 100644 --- a/source/Appccelerate.IO.Facts/AbsolutePathFacts.cs +++ b/source/Appccelerate.IO.Facts/AbsolutePathFacts.cs @@ -73,7 +73,7 @@ public void ThrowsException_WhenPathIsNotAbsolute() { Action action = () => new AbsolutePath("..\folder\file.ext"); - action.ShouldThrow(); + action.Should().Throw(); } [Theory] diff --git a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryDirectoryFacts.cs b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryDirectoryFacts.cs index a6d81dd..1b8d314 100644 --- a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryDirectoryFacts.cs +++ b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryDirectoryFacts.cs @@ -56,7 +56,7 @@ public void ThrowsIOExceptionOnDeletingADirectory_WhenDirectoryContainsAFile() Action action = () => this.testee.Delete(Folder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -67,7 +67,7 @@ public void ThrowsIOExceptionOnDeletingADirectory_WhenDirectoryContainsASubDirec Action action = () => this.testee.Delete(Folder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] diff --git a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileFacts.cs b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileFacts.cs index beb6dd6..20bd531 100644 --- a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileFacts.cs +++ b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileFacts.cs @@ -73,7 +73,7 @@ public void CopyDoesNotOverwriteExistingFileContentByDefault() Action action = () => this.testee.Copy(SourceFile, DestinationFile); - action.ShouldThrow(); + action.Should().Throw(); this.fileSystem.GetFile(DestinationFile) .Should().Equal(originalContent); } @@ -101,7 +101,7 @@ public void ThrowsDirectoryNotFoundExceptionOnCopyingAFile_WhenDestinationDirect Action action = () => this.testee.Copy(SourceFile, DestinationFile); - action.ShouldThrow(); + action.Should().Throw(); this.fileSystem.FileExists(DestinationFile) .Should().BeFalse(); } @@ -114,7 +114,7 @@ public void ThrowsDirectoryNotFoundExceptionOnCopyingAFileWithOverwriteFlag_When Action action = () => this.testee.Copy(SourceFile, DestinationFile, true); - action.ShouldThrow(); + action.Should().Throw(); this.fileSystem.FileExists(DestinationFile) .Should().BeFalse(); } diff --git a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileInfoFacts.cs b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileInfoFacts.cs index 0482f23..6370473 100644 --- a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileInfoFacts.cs +++ b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileInfoFacts.cs @@ -79,7 +79,7 @@ public void DoesNotOverwriteAFileOnCopyToByDefault() Action action = () => this.testee.CopyTo(destinationPath); - action.ShouldThrow(); + action.Should().Throw(); this.fileSystem.GetFile(destinationPath).Should().BeEquivalentTo(originalContent); } @@ -103,7 +103,7 @@ public void DoesNotOverwriteAFileOnCopyTo_WhenOverwriteFlagNotSet() Action action = () => this.testee.CopyTo(destinationPath, false); - action.ShouldThrow(); + action.Should().Throw(); this.fileSystem.GetFile(destinationPath).Should().BeEquivalentTo(originalContent); } @@ -114,7 +114,7 @@ public void ThrowsDirectoryNotFoundExceptionOnCopyTo_WhenDestinationDirectoryDoe Action action = () => this.testee.CopyTo(destinationPath); - action.ShouldThrow(); + action.Should().Throw(); this.fileSystem.FileExists(destinationPath) .Should().BeFalse(); } diff --git a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemExtensionsFacts.cs b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemExtensionsFacts.cs index bb4cac2..1649091 100644 --- a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemExtensionsFacts.cs +++ b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemExtensionsFacts.cs @@ -40,7 +40,7 @@ public void EnsuresDirectoryForFilePathExists() Action action = () => this.fileSystem.EnsureParentDirectoryExists(Path.Combine(directoryPath, "test.txt")); - action.ShouldNotThrow(); + action.Should().NotThrow(); } [Fact] @@ -51,7 +51,7 @@ public void ThrowsDirectoryNotFoundException_WhenDirectoryOfFilePathDoesNotExist Action action = () => this.fileSystem.EnsureParentDirectoryExists(Path.Combine(directoryPath, "butDifferent", "test.txt")); - action.ShouldThrow(); + action.Should().Throw(); } } } \ No newline at end of file diff --git a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemFacts.cs b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemFacts.cs index 60f149a..90cb419 100644 --- a/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemFacts.cs +++ b/source/Appccelerate.IO.Facts/Access/InMemory/InMemoryFileSystemFacts.cs @@ -99,7 +99,7 @@ public void ThrowsDirectoryNotFoundExceptionOnDeletingADirectory_WhenDirectoryDo { Action action = () => this.testee.DeleteDirectory(Folder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -156,7 +156,7 @@ public void ThrowsDirectoryNotFoundExceptionOnAddingAFile_WhenDirectoryDoesNotYe { Action action = () => this.testee.AddFile(FileInFolder, DummyFile); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -201,7 +201,7 @@ public void ThrowsDirectoryNotFoundExceptionOnDeletingAFile_WhenDirectoryDoesNot { Action action = () => this.testee.DeleteFile(FileInFolder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -227,7 +227,7 @@ public void ThrowsFileNotFoundExceptionOnMovingAFile_WhenFileDoesNotExist() Action action = () => this.testee.Move(FileInFolder, OtherFileInOtherFolder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -237,7 +237,7 @@ public void ThrowsDirectoryNotFoundExceptionOnMovingAFile_WhenSourceFolderDoesNo Action action = () => this.testee.Move(FileInFolder, OtherFileInOtherFolder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -266,7 +266,7 @@ public void ThrowsIOExceptionOnMovingAFile_WhenAlreadyAFileAtTargetExists() Action action = () => this.testee.Move(FileInFolder, OtherFileInOtherFolder); - action.ShouldThrow(); + action.Should().Throw(); this.testee.GetFile(OtherFileInOtherFolder) .Should().Equal(originalContent); } @@ -294,7 +294,7 @@ public void ThrowsFileNotFoundExceptionOnCopyingAFile_WhenFileDoesNotExist() Action action = () => this.testee.Copy(FileInFolder, OtherFileInOtherFolder, false); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -304,7 +304,7 @@ public void ThrowsDirectoryNotFoundExceptionOnCopyingAFile_WhenSourceFolderDoesN Action action = () => this.testee.Copy(FileInFolder, OtherFileInOtherFolder, false); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -333,7 +333,7 @@ public void ThrowsIOExceptionOnCopyingAFile_WhenAlreadyAFileAtTargetExistsAndOve Action action = () => this.testee.Copy(FileInFolder, OtherFileInOtherFolder, false); - action.ShouldThrow(); + action.Should().Throw(); this.testee.GetFile(OtherFileInOtherFolder) .Should().Equal(originalContent); } @@ -370,7 +370,7 @@ public void ThrowsAnFileNotFoundExceptionOnGettingAFile_WhenFileDoesNotExist() Action action = () => this.testee.GetFile(FileInFolder); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -378,7 +378,7 @@ public void ThrowsAnFileNotFoundExceptionOnGettingAFile_WhenDirectoryDoesNotExis { Action action = () => this.testee.GetFile(FileInFolder); - action.ShouldThrow(); + action.Should().Throw(); } } } diff --git a/source/Appccelerate.IO.Facts/Access/Internals/ExtensionProviderExtensionsFacts.cs b/source/Appccelerate.IO.Facts/Access/Internals/ExtensionProviderExtensionsFacts.cs index 078b41c..cb0213e 100644 --- a/source/Appccelerate.IO.Facts/Access/Internals/ExtensionProviderExtensionsFacts.cs +++ b/source/Appccelerate.IO.Facts/Access/Internals/ExtensionProviderExtensionsFacts.cs @@ -148,7 +148,7 @@ public void CallsFailWithCorrectExceptionAndRethrowsException_WhenUsingAction() e => e.EndDo(ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); A.CallTo(() => this.extension.FailDo(ref exception)).MustHaveHappened(); } @@ -169,7 +169,7 @@ public void RethrowsExchangedException_WhenUsingActionAndExtensionExchangesExcep e => e.EndDo(ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -191,7 +191,7 @@ public void RethrowsLastExchangedException_WhenUsingActionAndMultipleExtensionsE e => e.EndDo(ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -259,7 +259,7 @@ public void CallsFailWithCorrectExceptionAndRethrowsException_WhenUsingActionWit e => e.EndDo(ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -279,7 +279,7 @@ public void RethrowsExchangedException_WhenUsingActionWithOverloadAndExtensionEx e => e.EndDo(ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -301,7 +301,7 @@ public void RethrowsLastExchangedException_WhenUsingActionWithOverloadAndMultipl e => e.EndDo(ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -385,7 +385,7 @@ public void CallsFailWithCorrectExceptionAndRethrowsException_WhenUsingFunc() (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -405,7 +405,7 @@ public void RethrowsExchangedException_WhenUsingFuncAndExtensionExchangesExcepti (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDoReturn(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -427,7 +427,7 @@ public void RethrowsLastExchangedException_WhenUsingFuncAndMultipleExtensionsExc (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -495,7 +495,7 @@ public void CallsFailWithCorrectExceptionAndRethrowsException_WhenUsingFuncWithO (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -515,7 +515,7 @@ public void RethrowsExchangedException_WhenUsingFuncWithOverloadAndExtensionExch (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -537,7 +537,7 @@ public void RethrowsLastExchangedException_WhenUsingFuncWithOverloadAndMultipleE (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -586,7 +586,7 @@ public void CallsActionWithCorrectParameters_WhenUsingFuncWithOverloadAndExtensi (IExtension e, ref Exception ex) => e.FailDo(ref ex)); this.intParameter.Should().Be(ExpectedParameter); - result.Should().Be(this.expectedReturnStream); + result.Should().BeSameAs(this.expectedReturnStream); } [Fact] @@ -606,7 +606,7 @@ public void CallsFailWithCorrectParameters_WhenUsingFuncWithOverloadAndExtension (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDoReturn(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); A.CallTo(() => this.extension.FailDoReturn(ref exception)).MustHaveHappened(); } @@ -627,7 +627,7 @@ public void RethrowsExchangedException_WhenUsingFuncWithOverloadAndExtensionUsin (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -649,7 +649,7 @@ public void RethrowsLastExchangedException_WhenUsingFuncWithOverloadAndExtension (e, r) => e.EndDoReturn(r, ExpectedParameter), (IExtension e, ref Exception ex) => e.FailDo(ref ex)); - action.ShouldThrow(); + action.Should().Throw(); } private void RegisterExtensions(params IExtension[] extensions) diff --git a/source/Appccelerate.IO.Facts/Appccelerate.IO.Facts.csproj b/source/Appccelerate.IO.Facts/Appccelerate.IO.Facts.csproj index fd6eb09..03dbd08 100644 --- a/source/Appccelerate.IO.Facts/Appccelerate.IO.Facts.csproj +++ b/source/Appccelerate.IO.Facts/Appccelerate.IO.Facts.csproj @@ -1,124 +1,41 @@ - - - + - Debug - AnyCPU - {84AC6FB1-0734-4C60-96E2-8D386AA5CF09} - Library - Properties Appccelerate.IO - Appccelerate.IO.Facts - v4.5 - 512 - dc3b7f39 + net5.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + + + Appccelerate.IO.Facts + Copyright © 2008-2020 + Appccelerate team + Appccelerate + Appccelerate + - - ..\packages\FakeItEasy.1.25.1\lib\net40\FakeItEasy.dll - - - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.dll - - - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.Core.dll - - - - - - - - - - ..\packages\xunit.1.9.2\lib\net20\xunit.dll - True - - - ..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + - - - - - - - {040e4ba4-3ec0-4d60-b82f-2f375bf0dd29} - Appccelerate.IO - + + - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - + + + ../Analyzers.Facts.ruleset + \ No newline at end of file diff --git a/source/Appccelerate.IO.Facts/Csv/CsvParserFacts.cs b/source/Appccelerate.IO.Facts/Csv/CsvParserFacts.cs index e0ad1a5..4ae4b11 100644 --- a/source/Appccelerate.IO.Facts/Csv/CsvParserFacts.cs +++ b/source/Appccelerate.IO.Facts/Csv/CsvParserFacts.cs @@ -122,7 +122,7 @@ public void ParseUnvalidValuesNoQuote() { Action action = () => this.parser.Parse("\"00501, ABC"); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] @@ -130,7 +130,7 @@ public void ParseUnvalidValuesSpaceAfterQuote() { Action action = () => this.parser.Parse("\"00501\" , \"ABC\""); - action.ShouldThrow(); + action.Should().Throw(); } [Fact] diff --git a/source/Appccelerate.IO.Facts/NuGet.config b/source/Appccelerate.IO.Facts/NuGet.config deleted file mode 100644 index 5d5bc35..0000000 --- a/source/Appccelerate.IO.Facts/NuGet.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO.Facts/Properties/AssemblyInfo.cs b/source/Appccelerate.IO.Facts/Properties/AssemblyInfo.cs deleted file mode 100644 index 11a0335..0000000 --- a/source/Appccelerate.IO.Facts/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2008-2015 -// -// 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.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Appccelerate.IO.Facts")] -[assembly: AssemblyDescription("")] diff --git a/source/Appccelerate.IO.Facts/Properties/GlobalAssemblyInfo.cs b/source/Appccelerate.IO.Facts/Properties/GlobalAssemblyInfo.cs deleted file mode 100644 index 21da808..0000000 --- a/source/Appccelerate.IO.Facts/Properties/GlobalAssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2008-2015 -// -// 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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyCompany("Appccelerate")] -[assembly: AssemblyProduct("Appccelerate")] -[assembly: AssemblyCopyright("Copyright © 2008-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] diff --git a/source/Appccelerate.IO.Facts/Settings.stylecop b/source/Appccelerate.IO.Facts/Settings.stylecop deleted file mode 100644 index 0f7f7ab..0000000 --- a/source/Appccelerate.IO.Facts/Settings.stylecop +++ /dev/null @@ -1,70 +0,0 @@ - - - True - NoMerge - - - - - - \.g\.cs$ - \.Designer\.cs$ - \.generated\.cs$ - \.g\.i\.cs$ - TemporaryGeneratedFile_.*\.cs$ - AssemblyInfo_.*\.cs$ - - - - - - - - - - False - - - - - False - - - - - - - - - - False - - - - - - - - - - False - - - - - False - - - - - False - - - - - Appccelerate - Copyright (c) 2008-2015 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. - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO.Facts/ShortcutPathFacts.cs b/source/Appccelerate.IO.Facts/ShortcutPathFacts.cs index c3fc690..b7e9de8 100644 --- a/source/Appccelerate.IO.Facts/ShortcutPathFacts.cs +++ b/source/Appccelerate.IO.Facts/ShortcutPathFacts.cs @@ -69,7 +69,7 @@ public void ThrowsException_WhenInvalidShortcutPathIsAssigned() const string InvalidShortcutPath = ShortcutPath.ShortcutCharacter + "ShortcutT" + ShortcutPath.ShortcutCharacter + "ff" + ShortcutPath.ShortcutCharacter + @"\file.ext"; Action action = () => new ShortcutPath(InvalidShortcutPath); - action.ShouldThrow(); + action.Should().Throw(); } [Theory] diff --git a/source/Appccelerate.IO.Facts/Streams/StreamDecoratorStreamNoStreamFacts.cs b/source/Appccelerate.IO.Facts/Streams/StreamDecoratorStreamNoStreamFacts.cs index b149237..2730bf1 100644 --- a/source/Appccelerate.IO.Facts/Streams/StreamDecoratorStreamNoStreamFacts.cs +++ b/source/Appccelerate.IO.Facts/Streams/StreamDecoratorStreamNoStreamFacts.cs @@ -32,7 +32,7 @@ public void ThrowsInvalidOperationExceptin_WhenNoStreamIsAssigned() var streamDecorator = new StreamDecoratorTestStream(null); streamDecorator.Invoking(s => s.Position = 10) - .ShouldThrow(); + .Should().Throw(); } } } \ No newline at end of file diff --git a/source/Appccelerate.IO.Facts/packages.config b/source/Appccelerate.IO.Facts/packages.config deleted file mode 100644 index c1b0873..0000000 --- a/source/Appccelerate.IO.Facts/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO.Specs/Appccelerate.IO.Specs.csproj b/source/Appccelerate.IO.Specs/Appccelerate.IO.Specs.csproj deleted file mode 100644 index 9f0680b..0000000 --- a/source/Appccelerate.IO.Specs/Appccelerate.IO.Specs.csproj +++ /dev/null @@ -1,68 +0,0 @@ - - - - - Debug - AnyCPU - {C11EC975-2F3C-4376-B769-966BBB344C17} - Library - Properties - Appccelerate.IO - Appccelerate.IO.Specs - v4.5 - 512 - 5a60e347 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Machine.Specifications\lib\net45\Machine.Specifications.TDNetRunner.dll - - - - - - - - - - - - - - - - - - - {040e4ba4-3ec0-4d60-b82f-2f375bf0dd29} - Appccelerate.IO - - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO.Specs/Properties/AssemblyInfo.cs b/source/Appccelerate.IO.Specs/Properties/AssemblyInfo.cs deleted file mode 100644 index 41b0007..0000000 --- a/source/Appccelerate.IO.Specs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2008-2015 -// -// 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.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Appccelerate.IO.Specs")] -[assembly: AssemblyDescription("")] diff --git a/source/Appccelerate.IO.Specs/Settings.stylecop b/source/Appccelerate.IO.Specs/Settings.stylecop deleted file mode 100644 index 541e830..0000000 --- a/source/Appccelerate.IO.Specs/Settings.stylecop +++ /dev/null @@ -1,83 +0,0 @@ - - - True - NoMerge - - - - - - - False - - - - - False - - - - - False - - - - - False - - - - - - - - - - False - - - - - False - - - - - False - - - - - - - - - - False - - - - - False - - - - - False - - - - - - - - - - False - - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO.Specs/packages.config b/source/Appccelerate.IO.Specs/packages.config deleted file mode 100644 index bbeaf72..0000000 --- a/source/Appccelerate.IO.Specs/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO.Specs/ripple.dependencies.config b/source/Appccelerate.IO.Specs/ripple.dependencies.config deleted file mode 100644 index 9cdc7fc..0000000 --- a/source/Appccelerate.IO.Specs/ripple.dependencies.config +++ /dev/null @@ -1,6 +0,0 @@ -Appccelerate.Development -Appccelerate.Development.Specs -FakeItEasy -GitFlowVersionTask -RippleRestoreTask -StyleCop.MSBuild diff --git a/source/Appccelerate.IO/AbsolutePath.cs b/source/Appccelerate.IO/AbsolutePath.cs index 384d9d3..acd5b8e 100644 --- a/source/Appccelerate.IO/AbsolutePath.cs +++ b/source/Appccelerate.IO/AbsolutePath.cs @@ -62,7 +62,7 @@ public static implicit operator AbsolutePath(string absolutePath) public static implicit operator string(AbsolutePath absolutePath) { - Ensure.ArgumentNotNull(absolutePath, "absolutePath"); + Guard.AgainstNullArgument(nameof(absolutePath), absolutePath); return absolutePath.Value; } @@ -121,7 +121,7 @@ public override string ToString() private bool Equals(AbsolutePath other) { - Ensure.ArgumentNotNull(other, "other"); + Guard.AgainstNullArgument(nameof(other), other); return string.Equals(this.Value, other.Value); } diff --git a/source/Appccelerate.IO/Access/Internals/Directory.cs b/source/Appccelerate.IO/Access/Internals/Directory.cs index 6625300..4845b1d 100644 --- a/source/Appccelerate.IO/Access/Internals/Directory.cs +++ b/source/Appccelerate.IO/Access/Internals/Directory.cs @@ -73,7 +73,7 @@ public IDirectoryInfo CreateDirectory(string path) public IDirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity) { return this.EncapsulateWithExtension( - () => new DirectoryInfo(System.IO.Directory.CreateDirectory(path, directorySecurity)), + () => new DirectoryInfo(directorySecurity.CreateDirectory(path)), e => e.BeginCreateDirectory(path, directorySecurity), (e, r) => e.EndCreateDirectory(r, path, directorySecurity), (IDirectoryExtension e, ref Exception exception) => e.FailCreateDirectory(ref exception, path, directorySecurity)); @@ -143,7 +143,7 @@ public IEnumerable GetDirectories(string path) public DirectorySecurity GetAccessControl(string path) { return this.EncapsulateWithExtension( - () => System.IO.Directory.GetAccessControl(path), + () => new System.IO.DirectoryInfo(path).GetAccessControl(), e => e.BeginGetAccessControl(path), (e, r) => e.EndGetAccessControl(r, path), (IDirectoryExtension e, ref Exception exception) => e.FailGetAccessControl(ref exception, path)); @@ -153,7 +153,7 @@ public DirectorySecurity GetAccessControl(string path) public DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections) { return this.EncapsulateWithExtension( - () => System.IO.Directory.GetAccessControl(path, includeSections), + () => new System.IO.DirectoryInfo(path).GetAccessControl(includeSections), e => e.BeginGetAccessControl(path, includeSections), (e, r) => e.EndGetAccessControl(r, path, includeSections), (IDirectoryExtension e, ref Exception exception) => e.FailGetAccessControl(ref exception, path, includeSections)); @@ -314,7 +314,7 @@ public void Move(string sourceDirName, string destDirName) public void SetAccessControl(string path, DirectorySecurity directorySecurity) { this.EncapsulateWithExtension( - () => System.IO.Directory.SetAccessControl(path, directorySecurity), + () => new System.IO.DirectoryInfo(path).SetAccessControl(directorySecurity), e => e.BeginSetAccessControl(path, directorySecurity), e => e.EndSetAccessControl(path, directorySecurity), (IDirectoryExtension e, ref Exception exception) => e.FailSetAccessControl(ref exception, path, directorySecurity)); diff --git a/source/Appccelerate.IO/Access/Internals/File.cs b/source/Appccelerate.IO/Access/Internals/File.cs index 089d60d..38dfcc6 100644 --- a/source/Appccelerate.IO/Access/Internals/File.cs +++ b/source/Appccelerate.IO/Access/Internals/File.cs @@ -366,7 +366,7 @@ public Stream Create(string path, int bufferSize, FileOptions options) public Stream Create(string path, int bufferSize, FileOptions options, FileSecurity fileSecurity) { return this.EncapsulateWithExtension( - () => System.IO.File.Create(path, bufferSize, options, fileSecurity), + () => new System.IO.FileInfo(path).Create(FileMode.Create, FileSystemRights.Read | FileSystemRights.Write, FileShare.None, bufferSize, options, fileSecurity), e => e.BeginCreate(path, bufferSize, options, fileSecurity), (e, r) => e.EndCreate(r, path, bufferSize, options, fileSecurity), (IFileExtension e, ref Exception exception) => e.FailCreate(ref exception, path, bufferSize, options, fileSecurity)); @@ -395,8 +395,8 @@ public void Encrypt(string path) /// public FileSecurity GetAccessControl(string path) { - return this.EncapsulateWithExtension( - () => System.IO.File.GetAccessControl(path), + return this.EncapsulateWithExtension( + () => new System.IO.FileInfo(path).GetAccessControl(), e => e.BeginGetAccessControl(path), (e, r) => e.EndGetAccessControl(r, path), (IFileExtension e, ref Exception exception) => e.FailGetAccessControl(ref exception, path)); @@ -406,7 +406,7 @@ public FileSecurity GetAccessControl(string path) public FileSecurity GetAccessControl(string path, AccessControlSections includeSections) { return this.EncapsulateWithExtension( - () => System.IO.File.GetAccessControl(path, includeSections), + () => new System.IO.FileInfo(path).GetAccessControl(includeSections), e => e.BeginGetAccessControl(path, includeSections), (e, r) => e.EndGetAccessControl(r, path, includeSections), (IFileExtension e, ref Exception exception) => e.FailGetAccessControl(ref exception, path, includeSections)); @@ -536,7 +536,7 @@ public void Replace(string sourceFileName, string destinationFileName, string de public void SetAccessControl(string path, FileSecurity fileSecurity) { this.EncapsulateWithExtension( - () => System.IO.File.SetAccessControl(path, fileSecurity), + () => new System.IO.FileInfo(path).SetAccessControl(fileSecurity), e => e.BeginSetAccessControl(path, fileSecurity), e => e.EndSetAccessControl(path, fileSecurity), (IFileExtension e, ref Exception exception) => e.FailSetAccessControl(ref exception, path, fileSecurity)); diff --git a/source/Appccelerate.IO/Access/Internals/FileSystemInfo{TInfo}.cs b/source/Appccelerate.IO/Access/Internals/FileSystemInfo{TInfo}.cs index 6079fda..470ecf1 100644 --- a/source/Appccelerate.IO/Access/Internals/FileSystemInfo{TInfo}.cs +++ b/source/Appccelerate.IO/Access/Internals/FileSystemInfo{TInfo}.cs @@ -163,30 +163,6 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte this.Info.GetObjectData(info, context); } - /// - /// Creates an object that contains all the relevant information required to - /// generate a proxy used to communicate with a remote object. - /// - /// The of the object that - /// the new will reference. - /// - /// Information required to generate a proxy. - /// - /// - /// This instance is not a valid remoting object. - /// - /// - /// The immediate caller does not have infrastructure permission. - /// - /// - /// - /// - [SecurityCritical] - public override System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType) - { - return this.Info.CreateObjRef(requestedType); - } - /// /// Obtains a lifetime service object to control the lifetime policy for this instance. /// diff --git a/source/Appccelerate.IO/Appccelerate.IO.csproj b/source/Appccelerate.IO/Appccelerate.IO.csproj index d0b32d4..2e2267f 100644 --- a/source/Appccelerate.IO/Appccelerate.IO.csproj +++ b/source/Appccelerate.IO/Appccelerate.IO.csproj @@ -1,156 +1,86 @@ - - - + - Debug - AnyCPU - {040E4BA4-3EC0-4D60-B82F-2F375BF0DD29} - Library - Properties - Appccelerate.IO - Appccelerate.IO - v4.5 - 512 - 03af2c48 + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + + + Appccelerate.IO + Copyright © 2008-2020 + Appccelerate team + Appccelerate + Appccelerate - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Appccelerate.IO.XML - 1591 + + + + False + LICENSE + https://github.com/appccelerate/io + true + true + true + icon.png + + Provides functionality for simplified IO operations: + File system abstraction (completely testable) + Stream decorators/interceptors, + loader for resources (from file/embedded) + + + 3.0.0: + - Supports now .NET Standard 2.0 + + Appccelerate io + + - + true + snupkg - - - ..\packages\Appccelerate.Fundamentals.2.8.0\lib\portable-windows8+net45\Appccelerate.Fundamentals.dll - - - - - + + + + True + Appccelerate.snk + False + + + + + ../Analyzers.Productive.ruleset + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + Minor + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + - - - - + + - - - - - - - - + + - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO/Csv/CsvParser.cs b/source/Appccelerate.IO/Csv/CsvParser.cs index 66b7a87..f91fe85 100644 Binary files a/source/Appccelerate.IO/Csv/CsvParser.cs and b/source/Appccelerate.IO/Csv/CsvParser.cs differ diff --git a/source/Appccelerate.IO/Csv/CsvWriter.cs b/source/Appccelerate.IO/Csv/CsvWriter.cs index 1f7bc33..c5e9842 100644 --- a/source/Appccelerate.IO/Csv/CsvWriter.cs +++ b/source/Appccelerate.IO/Csv/CsvWriter.cs @@ -54,7 +54,7 @@ public string Write(string[] values) /// public string Write(string[] values, string delimiter) { - Ensure.ArgumentNotNull(values, "values"); + Guard.AgainstNullArgument(nameof(values), values); StringBuilder line = new StringBuilder(); foreach (string value in values) diff --git a/source/Appccelerate.IO/ExceptionExtensionMethods.cs b/source/Appccelerate.IO/ExceptionExtensionMethods.cs index 521e691..9c3d67e 100644 --- a/source/Appccelerate.IO/ExceptionExtensionMethods.cs +++ b/source/Appccelerate.IO/ExceptionExtensionMethods.cs @@ -30,7 +30,7 @@ public static class ExceptionExtensionMethods /// Returns the specified exception to allow writing throw exception.preserveStackTrace(). public static Exception PreserveStackTrace(this Exception exception) { - Ensure.ArgumentNotNull(exception, "exception"); + Guard.AgainstNullArgument(nameof(exception), exception); #if !SILVERLIGHT var remoteStackTraceString = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); diff --git a/source/Appccelerate.IO/Guard.cs b/source/Appccelerate.IO/Guard.cs new file mode 100644 index 0000000..26bfb01 --- /dev/null +++ b/source/Appccelerate.IO/Guard.cs @@ -0,0 +1,131 @@ +namespace Appccelerate.IO +{ + using System; + using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; + using System.Globalization; + using System.Reflection; + + /// + /// Provides guard clauses. + /// + internal static class Guard + { + /// + /// Guards against a null argument. + /// + /// The type of the argument. + /// Name of the parameter. + /// The argument. + /// is null. + /// is restricted to reference types to avoid boxing of value type objects. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")] + [DebuggerStepThrough] + public static void AgainstNullArgument(string parameterName, [ValidatedNotNull]TArgument argument) + where TArgument : class + { + if (argument == null) + { + throw new ArgumentNullException(parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null.", parameterName)); + } + } + + /// + /// Guards against a null argument if can be null. + /// + /// The type of the argument. + /// Name of the parameter. + /// The argument. + /// is null. + /// + /// Performs a type check to avoid boxing of value type objects. + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")] + [DebuggerStepThrough] + public static void AgainstNullArgumentIfNullable(string parameterName, [ValidatedNotNull]TArgument argument) + { + if (typeof(TArgument).IsNullableType() && argument == null) + { + throw new ArgumentNullException(parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null.", parameterName)); + } + } + + /// + /// Guards against a null argument or empty strings. + /// + /// Name of the parameter. + /// The argument. + /// is null or empty. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")] + [DebuggerStepThrough] + public static void AgainstNullOrEmpty(string parameterName, [ValidatedNotNull]string argument) + { + if (string.IsNullOrEmpty(argument)) + { + throw new ArgumentException(parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null or empty.", parameterName)); + } + } + + /// + /// Guards against a null argument property value. + /// + /// The type of the property. + /// Name of the parameter. + /// Name of the property. + /// The argument property. + /// is null. + /// is restricted to reference types to avoid boxing of value type objects. + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")] + [DebuggerStepThrough] + public static void AgainstNullArgumentProperty(string parameterName, string propertyName, [ValidatedNotNull]TProperty argumentProperty) + where TProperty : class + { + if (argumentProperty == null) + { + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "{0}.{1} is null.", parameterName, propertyName), parameterName); + } + } + + /// + /// Guards against a null argument property value if can be null. + /// + /// The type of the property. + /// Name of the parameter. + /// Name of the property. + /// The argument property. + /// is null. + /// + /// Performs a type check to avoid boxing of value type objects. + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")] + [DebuggerStepThrough] + public static void AgainstNullArgumentPropertyIfNullable( + string parameterName, string propertyName, [ValidatedNotNull]TProperty argumentProperty) + { + if (typeof(TProperty).IsNullableType() && argumentProperty == null) + { + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "{0}.{1} is null.", parameterName, propertyName), parameterName); + } + } + + /// + /// Determines whether the specified type is a nullable type. + /// + /// The type. + /// + /// true if the specified type is a nullable type; otherwise, false. + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")] + private static bool IsNullableType(this Type type) + { + return !type.GetTypeInfo().IsValueType || (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)); + } + + /// + /// When applied to a parameter, this attribute provides an indication to code analysis that the argument has been null checked. + /// + private sealed class ValidatedNotNullAttribute : Attribute + { + } + } +} \ No newline at end of file diff --git a/source/Appccelerate.IO/NuGet.config b/source/Appccelerate.IO/NuGet.config deleted file mode 100644 index 5d5bc35..0000000 --- a/source/Appccelerate.IO/NuGet.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO/Properties/AssemblyInfo.cs b/source/Appccelerate.IO/Properties/AssemblyInfo.cs deleted file mode 100644 index fef7320..0000000 --- a/source/Appccelerate.IO/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2008-2015 -// -// 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.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Appccelerate.IO")] -[assembly: AssemblyDescription("")] - -[assembly: CLSCompliant(true)] diff --git a/source/Appccelerate.IO/Properties/GlobalAssemblyInfo.cs b/source/Appccelerate.IO/Properties/GlobalAssemblyInfo.cs deleted file mode 100644 index 21da808..0000000 --- a/source/Appccelerate.IO/Properties/GlobalAssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2008-2015 -// -// 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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyCompany("Appccelerate")] -[assembly: AssemblyProduct("Appccelerate")] -[assembly: AssemblyCopyright("Copyright © 2008-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] diff --git a/source/Appccelerate.IO/Resources/EmbeddedResourceLoader.cs b/source/Appccelerate.IO/Resources/EmbeddedResourceLoader.cs index e57a91d..c2961f1 100644 --- a/source/Appccelerate.IO/Resources/EmbeddedResourceLoader.cs +++ b/source/Appccelerate.IO/Resources/EmbeddedResourceLoader.cs @@ -41,7 +41,7 @@ public class EmbeddedResourceLoader : IResourceLoader /// does not exist public IXPathNavigable LoadResourceAsXml(Type type, string resourceName) { - Ensure.ArgumentNotNull(type, "type"); + Guard.AgainstNullArgument(nameof(type), type); return this.LoadResourceAsXml(type.Assembly, string.Format(CultureInfo.InvariantCulture, "{0}.{1}", type.Namespace, resourceName)); } @@ -75,7 +75,7 @@ public IXPathNavigable LoadResourceAsXml(Assembly assembly, string resourceName) /// public string LoadResourceAsString(Type type, string resourceName) { - Ensure.ArgumentNotNull(type, "type"); + Guard.AgainstNullArgument(nameof(type), type); return this.LoadResourceAsString(type.Assembly, string.Format(CultureInfo.InvariantCulture, "{0}.{1}", type.Namespace, resourceName)); } @@ -92,7 +92,7 @@ public string LoadResourceAsString(Type type, string resourceName) Justification = "cannot be used otherwise")] public string LoadResourceAsString(Assembly assembly, string resourceName) { - Ensure.ArgumentNotNull(assembly, "assembly"); + Guard.AgainstNullArgument(nameof(assembly), assembly); using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) { @@ -119,7 +119,7 @@ public string LoadResourceAsString(Assembly assembly, string resourceName) /// public MemoryStream LoadResourceAsStream(Type type, string resourceName) { - Ensure.ArgumentNotNull(type, "type"); + Guard.AgainstNullArgument(nameof(type), type); return this.LoadResourceAsStream(type.Assembly, string.Format(CultureInfo.InvariantCulture, "{0}.{1}", type.Namespace, resourceName)); } @@ -136,7 +136,7 @@ public MemoryStream LoadResourceAsStream(Type type, string resourceName) Justification = "it's a memory stream and has to be disposed by caller")] public MemoryStream LoadResourceAsStream(Assembly assembly, string resourceName) { - Ensure.ArgumentNotNull(assembly, "assembly"); + Guard.AgainstNullArgument(nameof(assembly), assembly); using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) { diff --git a/source/Appccelerate.IO/Resources/FileResourceLoader.cs b/source/Appccelerate.IO/Resources/FileResourceLoader.cs index 6bd676e..283b2dc 100644 --- a/source/Appccelerate.IO/Resources/FileResourceLoader.cs +++ b/source/Appccelerate.IO/Resources/FileResourceLoader.cs @@ -39,7 +39,7 @@ public class FileResourceLoader : IResourceLoader /// public IXPathNavigable LoadResourceAsXml(Type type, string resourceName) { - Ensure.ArgumentNotNull(type, "type"); + Guard.AgainstNullArgument(nameof(type), type); return this.LoadResourceAsXml(type.Assembly, resourceName); } @@ -54,7 +54,7 @@ public IXPathNavigable LoadResourceAsXml(Type type, string resourceName) /// public IXPathNavigable LoadResourceAsXml(Assembly assembly, string resourceName) { - Ensure.ArgumentNotNull(assembly, "assembly"); + Guard.AgainstNullArgument(nameof(assembly), assembly); XmlDocument xmlDocument = new XmlDocument(); string filepath = Path.Combine(Path.GetDirectoryName(assembly.Location), resourceName); @@ -73,7 +73,7 @@ public IXPathNavigable LoadResourceAsXml(Assembly assembly, string resourceName) /// public string LoadResourceAsString(Type type, string resourceName) { - Ensure.ArgumentNotNull(type, "type"); + Guard.AgainstNullArgument(nameof(type), type); return this.LoadResourceAsString(type.Assembly, resourceName); } @@ -88,7 +88,7 @@ public string LoadResourceAsString(Type type, string resourceName) /// public string LoadResourceAsString(Assembly assembly, string resourceName) { - Ensure.ArgumentNotNull(assembly, "assembly"); + Guard.AgainstNullArgument(nameof(assembly), assembly); string filepath = Path.Combine(Path.GetDirectoryName(assembly.Location), resourceName); using (StreamReader reader = new StreamReader(filepath)) @@ -107,7 +107,7 @@ public string LoadResourceAsString(Assembly assembly, string resourceName) /// public MemoryStream LoadResourceAsStream(Type type, string resourceName) { - Ensure.ArgumentNotNull(type, "type"); + Guard.AgainstNullArgument(nameof(type), type); return this.LoadResourceAsStream(type.Assembly, resourceName); } @@ -124,7 +124,7 @@ public MemoryStream LoadResourceAsStream(Type type, string resourceName) Justification = "it's a memory stream and has to be disposed by caller")] public MemoryStream LoadResourceAsStream(Assembly assembly, string resourceName) { - Ensure.ArgumentNotNull(assembly, "assembly"); + Guard.AgainstNullArgument(nameof(assembly), assembly); var result = new MemoryStream(); string filepath = Path.Combine(Path.GetDirectoryName(assembly.Location), resourceName); diff --git a/source/Appccelerate.IO/Settings.stylecop b/source/Appccelerate.IO/Settings.stylecop deleted file mode 100644 index 4f59a13..0000000 --- a/source/Appccelerate.IO/Settings.stylecop +++ /dev/null @@ -1,106 +0,0 @@ - - - - async - args - serializer - serialized - deserialized - deserialize - csv - remoting - - NoMerge - - - - - - \.g\.cs$ - \.Designer\.cs$ - \.generated\.cs$ - \.g\.i\.cs$ - TemporaryGeneratedFile_.*\.cs$ - AssemblyInfo_.*\.cs$ - - - - - - - - - - False - - - - - False - - - - - False - - - - - False - - - - - False - - - - - False - - - - - False - - - - - Appccelerate - Copyright (c) 2008-2015 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. - False - True - - - - - - - False - - - - - - - - - - False - - - - - - - - - - False - - - - - - - \ No newline at end of file diff --git a/source/Appccelerate.IO/ShortcutPath.cs b/source/Appccelerate.IO/ShortcutPath.cs index 1641f21..074ed37 100644 --- a/source/Appccelerate.IO/ShortcutPath.cs +++ b/source/Appccelerate.IO/ShortcutPath.cs @@ -27,7 +27,7 @@ public class ShortcutPath public ShortcutPath(string shortcutPath) { - Ensure.ArgumentNotNull(shortcutPath, "shortcutPath"); + Guard.AgainstNullArgument(nameof(shortcutPath), shortcutPath); if (ContainsInvalidShortcut(shortcutPath)) { diff --git a/source/Appccelerate.IO/Streams/StreamExtensionMethods.cs b/source/Appccelerate.IO/Streams/StreamExtensionMethods.cs index 21fe287..758d9a7 100644 --- a/source/Appccelerate.IO/Streams/StreamExtensionMethods.cs +++ b/source/Appccelerate.IO/Streams/StreamExtensionMethods.cs @@ -88,8 +88,8 @@ public static void CopyTo(this Stream input, Stream output) /// public static bool CompareStreamContentsTo(this Stream actual, Stream expected) { - Ensure.ArgumentNotNull(actual, "actual"); - Ensure.ArgumentNotNull(expected, "expected"); + Guard.AgainstNullArgument(nameof(actual), actual); + Guard.AgainstNullArgument(nameof(expected), expected); if (!expected.CanRead) { diff --git a/source/Appccelerate.IO/TemporaryFileHolder.cs b/source/Appccelerate.IO/TemporaryFileHolder.cs index 7c5eed8..a7bae42 100644 --- a/source/Appccelerate.IO/TemporaryFileHolder.cs +++ b/source/Appccelerate.IO/TemporaryFileHolder.cs @@ -38,7 +38,7 @@ public class TemporaryFileHolder : IDisposable /// Content of the file. public TemporaryFileHolder(string filePath, Stream fileContent) { - Ensure.ArgumentNotNull(fileContent, "fileContent"); + Guard.AgainstNullArgument(nameof(fileContent), fileContent); this.filePath = filePath; using (FileStream fileStream = File.Create(filePath)) diff --git a/source/Appccelerate.IO/icon.png b/source/Appccelerate.IO/icon.png new file mode 100644 index 0000000..6ec33d4 Binary files /dev/null and b/source/Appccelerate.IO/icon.png differ diff --git a/source/Appccelerate.IO/packages.config b/source/Appccelerate.IO/packages.config deleted file mode 100644 index bbed3dd..0000000 --- a/source/Appccelerate.IO/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file