diff --git a/Mime-Detective.sln b/Mime-Detective.sln index 505fe5e..3c02df6 100644 --- a/Mime-Detective.sln +++ b/Mime-Detective.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{098944FB-C1C9-48BE-AA37-CD3C5C336A84}" ProjectSection(SolutionItems) = preProject @@ -9,15 +9,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution appveyor.yml = appveyor.yml Build.ps1 = Build.ps1 build.sh = build.sh - global.json = global.json LICENSE = LICENSE NuGet.config = NuGet.config README.md = README.md EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mime-Detective", "src\Mime-Detective\Mime-Detective.xproj", "{9E3066B2-B987-4E32-83D4-16A20E3BA219}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mime-Detective.Tests", "test\Mime-Detective.Tests\Mime-Detective.Tests.csproj", "{CB3A9BEA-C247-4FEB-8670-98E3034FC214}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mime-Detective.Tests", "test\Mime-Detective.Tests\Mime-Detective.Tests.xproj", "{CB3A9BEA-C247-4FEB-8670-98E3034FC214}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{17C4E0DE-B863-4A81-B755-62E663D041F1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A50202E7-0386-4EB3-B09C-00EFCAE360F7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mime-Detective", "src\Mime-Detective\Mime-Detective.csproj", "{40608F32-BF6E-4DE4-85AE-EF71C69EF18D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -25,16 +28,20 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9E3066B2-B987-4E32-83D4-16A20E3BA219}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9E3066B2-B987-4E32-83D4-16A20E3BA219}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9E3066B2-B987-4E32-83D4-16A20E3BA219}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9E3066B2-B987-4E32-83D4-16A20E3BA219}.Release|Any CPU.Build.0 = Release|Any CPU {CB3A9BEA-C247-4FEB-8670-98E3034FC214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB3A9BEA-C247-4FEB-8670-98E3034FC214}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB3A9BEA-C247-4FEB-8670-98E3034FC214}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB3A9BEA-C247-4FEB-8670-98E3034FC214}.Release|Any CPU.Build.0 = Release|Any CPU + {40608F32-BF6E-4DE4-85AE-EF71C69EF18D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40608F32-BF6E-4DE4-85AE-EF71C69EF18D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40608F32-BF6E-4DE4-85AE-EF71C69EF18D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40608F32-BF6E-4DE4-85AE-EF71C69EF18D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {CB3A9BEA-C247-4FEB-8670-98E3034FC214} = {A50202E7-0386-4EB3-B09C-00EFCAE360F7} + {40608F32-BF6E-4DE4-85AE-EF71C69EF18D} = {17C4E0DE-B863-4A81-B755-62E663D041F1} + EndGlobalSection EndGlobal diff --git a/appveyor.yml b/appveyor.yml index cde58c2..35afd9f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,9 +5,9 @@ configuration: Release install: - mklink /J Data "test/Mime-Detective.Tests/Data" - ps: mkdir -Force ".\build\" | Out-Null - - ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1" + - ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1" - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" - - ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-1-003177' + - ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0' - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" build_script: - ps: ./Build.ps1 diff --git a/src/Mime-Detective/FileType.cs b/src/Mime-Detective/FileType.cs index 73a3a3a..cb98635 100644 --- a/src/Mime-Detective/FileType.cs +++ b/src/Mime-Detective/FileType.cs @@ -10,8 +10,11 @@ namespace MimeDetective public class FileType { public byte?[] Header { get; } + public ushort HeaderOffset { get; } + public string Extension { get; } + public string Mime { get; } /// @@ -24,11 +27,8 @@ public class FileType /// The description of MIME. public FileType(byte?[] header, string extension, string mime, ushort offset = 0) { - //header cannot be null, file type normal operation requires the data - if (header == null) - throw new ArgumentNullException(nameof(header), "cannot be null, FileType needs file header data"); + Header = header ?? throw new ArgumentNullException(nameof(header), $"cannot be null, {nameof(FileType)} needs file header data"); - Header = header; HeaderOffset = offset; Extension = extension; Mime = mime; diff --git a/src/Mime-Detective/Mime-Detective.csproj b/src/Mime-Detective/Mime-Detective.csproj new file mode 100644 index 0000000..bd5fd64 --- /dev/null +++ b/src/Mime-Detective/Mime-Detective.csproj @@ -0,0 +1,41 @@ + + + + Mime-Detective is group of classes for speeding Asp.Net Core development + Mime-Detective + 0.0.2 + Joshua Clark + netstandard1.3;net45 + Mime-Detective + Mime-Detective + mvc;ef;generic;utilities + https://github.com/clarkis117/GenericMvcUtilities + https://github.com/clarkis117/GenericMvcUtilities/blob/master/License.txt + git + https://github.com/clarkis117/GenericMvcUtilities.git + $(PackageTargetFallback);portable-net451+win8 + false + false + false + false + false + false + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Mime-Detective/Mime-Detective.xproj b/src/Mime-Detective/Mime-Detective.xproj deleted file mode 100644 index 7ccb7e2..0000000 --- a/src/Mime-Detective/Mime-Detective.xproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 9e3066b2-b987-4e32-83d4-16a20e3ba219 - MimeDetective - ..\artifacts\obj\$(MSBuildProjectName) - .\bin\ - - - 2.0 - - - - - - - - \ No newline at end of file diff --git a/src/Mime-Detective/MimeTypes.cs b/src/Mime-Detective/MimeTypes.cs index 7d30e12..f2c81cb 100644 --- a/src/Mime-Detective/MimeTypes.cs +++ b/src/Mime-Detective/MimeTypes.cs @@ -245,15 +245,15 @@ public static FileType GetFileType(FileInfo file) /// FileType or null not identified public static FileType GetFileType(Func> fileHeaderReadFunc, Stream stream = null, byte[] data = null) { - return getFileType(fileHeaderReadFunc(), stream, data); + return GetFileType(fileHeaderReadFunc(), stream, data); } public static async Task GetFileTypeAsync(Func>> fileHeaderReadFunc, Stream stream = null, byte[] data = null) { - return getFileType(await fileHeaderReadFunc(), stream, data); + return GetFileType(await fileHeaderReadFunc(), stream, data); } - private static FileType getFileType(IReadOnlyList fileHeader, Stream stream = null, byte[] data = null) + private static FileType GetFileType(IReadOnlyList fileHeader, Stream stream = null, byte[] data = null) { if (stream == null && data == null) throw new ArgumentNullException($"{nameof(stream)} : {nameof(data)}", "both file data arguments are null"); @@ -274,7 +274,7 @@ private static FileType getFileType(IReadOnlyList fileHeader, Stream strea // there may be situations where the file name is not given if (type.Equals(ZIP)) { - using (Stream fileData = stream != null ? stream : new MemoryStream(data)) + using (Stream fileData = stream ?? new MemoryStream(data)) { if (fileData.Position > 0) fileData.Seek(0, SeekOrigin.Begin); diff --git a/src/Mime-Detective/project.json b/src/Mime-Detective/project.json deleted file mode 100644 index 5caaa5f..0000000 --- a/src/Mime-Detective/project.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "packOptions": { - "summary": "Mime-Detective Class Library, .NET Core Fork", - "tags": [ "mime", "mime-type", "content-type", "contenttype" ], - "owners": [ "clarkis117" ], - "projectUrl": "https://github.com/clarkis117/Mime-Detective", - "licenseUrl": "https://github.com/clarkis117/Mime-Detective/blob/master/LICENSE", - "repository": { - "type": "git", - "url": "https://github.com/clarkis117/Mime-Detective.git" - } - }, - - "name": "Mime-Detective", - "title": "Mime-Detective", - "version": "0.0.2", - "description": "Mime-Detective Class Library, .NET Core Fork", - "authors": [ "Mime-Detective Collaborators" ], - - "dependencies": { - "NETStandard.Library": "1.6.1" - }, - - "frameworks": { - "net4.5": { - "frameworkAssemblies": { - "System.IO.Compression": "*", - "System.Xml": "*" - } - }, - "net4.5.1": { - "frameworkAssemblies": { - "System.IO.Compression": "*", - "System.Xml": "*" - } - }, - "net4.5.2": { - "frameworkAssemblies": { - "System.IO.Compression": "*", - "System.Xml": "*" - } - }, - "net4.6": { - "frameworkAssemblies": { - "System.IO.Compression": "*", - "System.Xml": "*" - } - }, - "net4.6.1": { - "frameworkAssemblies": { - "System.IO.Compression": "*", - "System.Xml": "*" - } - }, - "net4.6.2": { - "frameworkAssemblies": { - "System.IO.Compression": "*", - "System.Xml": "*" - } - }, - "netstandard1.3": { - "dependencies": { - "System.Xml.XmlSerializer": "*" - } - } - } -} diff --git a/test/Mime-Detective.Tests/Mime-Detective.Tests.csproj b/test/Mime-Detective.Tests/Mime-Detective.Tests.csproj new file mode 100644 index 0000000..bc6427b --- /dev/null +++ b/test/Mime-Detective.Tests/Mime-Detective.Tests.csproj @@ -0,0 +1,44 @@ + + + + netcoreapp1.1;net452;net462 + Mime-Detective.Tests + Mime-Detective.Tests + true + 1.1.1 + false + false + false + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Mime-Detective.Tests/Mime-Detective.Tests.xproj b/test/Mime-Detective.Tests/Mime-Detective.Tests.xproj deleted file mode 100644 index aff48a8..0000000 --- a/test/Mime-Detective.Tests/Mime-Detective.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - cb3a9bea-c247-4feb-8670-98e3034fc214 - MimeDetectiveTests - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Mime-Detective.Tests/project.json b/test/Mime-Detective.Tests/project.json deleted file mode 100644 index 0a69456..0000000 --- a/test/Mime-Detective.Tests/project.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "testRunner": "xunit", - - "dependencies": { - "Mime-Detective": { "target": "project" }, - "xunit": "2.2.0", - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "NETStandard.Library": "1.6.1" - }, - - "buildOptions": {"copyToOutput": "Data\\"}, - - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.1.0" - } - } - }, - "net4.5.1": { - }, - "net4.5.2": { - }, - "net4.6": { - }, - "net4.6.1": { - - }, - "net4.6.2": { - - } - } -} \ No newline at end of file