Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change namespaces to Pleosoft.XdeltaSharp and warning cleaning #7

Merged
merged 3 commits into from Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/settings.json
Expand Up @@ -13,4 +13,11 @@
"editor.formatOnType": true
},
"prettier.proseWrap": "always",
"cSpell.words": [
"Diagnoser",
"Lzma",
"Pleosoft",
"VCDIFF",
"Xdelta"
],
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Expand Up @@ -18,7 +18,7 @@
"command": "dotnet",
"args": [
"cake",
"--target=Build"
"--target=CleanBuild"
],
"group": {
"kind": "build",
Expand Down
14 changes: 14 additions & 0 deletions build.cake
Expand Up @@ -14,6 +14,20 @@ Task("Define-Project")
info.PreviewNuGetFeed = "https://pkgs.dev.azure.com/pleonex/Pleosoft/_packaging/Pleosoft-Preview/nuget/v3/index.json";
});

Task("Clean")
.Does<BuildInfo>(info =>
{
var settings = new DotNetCoreCleanSettings {
Configuration = info.Configuration,
};
DotNetCoreClean(info.SolutionFile, settings);
});

Task("CleanBuild")
.IsDependentOn("Define-Project")
.IsDependentOn("Clean")
.IsDependentOn("Build");

Task("Default")
.IsDependentOn("Stage-Artifacts");

Expand Down
2 changes: 1 addition & 1 deletion docs/toc.yml
Expand Up @@ -8,4 +8,4 @@
href: dev/

- name: GitHub
href: https://github.com/pleonex/xdelta-template
href: https://github.com/pleonex/xdelta-sharp
10 changes: 6 additions & 4 deletions src/.editorconfig
Expand Up @@ -30,7 +30,7 @@ dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning

### Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
dotnet_style_readonly_field = true:warning

### Parentheses preferences
Expand Down Expand Up @@ -173,16 +173,18 @@ dotnet_diagnostic.SA1633.severity = none # No XML-format header in source files
### SonarAnalyzer
dotnet_diagnostic.S1135.severity = suggestion # It's almost inevitable to have TODO but add bug ID

dotnet_diagnostic.CS1591.severity = none # Disable documentation
dotnet_diagnostic.SA0001.severity = none # Disable documentation
dotnet_diagnostic.SA1600.severity = none # Disable documentation
dotnet_diagnostic.SA1602.severity = none # Disable documentation

# Special rules for test projects
[*Tests/**]
dotnet_diagnostic.CS1591.severity = none # Disable documentation
dotnet_diagnostic.CA1001.severity = none # No need to implement IDisposable in test classes with cleanup.
dotnet_diagnostic.CA1034.severity = none # Public types in test classes for testing implementations
dotnet_diagnostic.CA1040.severity = none # Empty interfaces for testing
dotnet_diagnostic.CA1062.severity = none # No need to validate args in test methods
dotnet_diagnostic.CA1305.severity = none # No culture method for quick test code
dotnet_diagnostic.CA1307.severity = none # No culture method for quick test code
dotnet_diagnostic.SA0001.severity = none # Disable documentation
dotnet_diagnostic.SA1600.severity = none # Disable documentation
dotnet_diagnostic.S2699.severity = none # Assert may be in helper methods
dotnet_diagnostic.S3966.severity = none # Dispose twice to test implementation
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<AssemblyName>XdeltaSharp</AssemblyName>
<Description>Decompressor of VCDIFF patch files (RFC3284).</Description>
<RootNamespace>Pleosoft.XdeltaSharp.Cli</RootNamespace>
<TargetFramework>net5.0</TargetFramework>

<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
Expand Down
24 changes: 13 additions & 11 deletions src/Pleosoft.XdeltaSharp.Cli/Program.cs
Expand Up @@ -17,25 +17,27 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.IO;
using System.Diagnostics;

namespace Xdelta.Cli
namespace Pleosoft.XdeltaSharp.Cli
{
class MainClass
using System;
using System.Diagnostics;
using System.IO;
using Pleosoft.XdeltaSharp.Decoder;

public static class Program
{
public static void Main(string[] args)
{
if (args.Length != 3)
return;

Stopwatch watcher = Stopwatch.StartNew();
using FileStream source = OpenForRead(args[0]);
using FileStream patch = OpenForRead(args[1]);
using FileStream target = CreateForWriteAndRead(args[2]);

using (FileStream source = OpenForRead(args[0]))
using (FileStream patch = OpenForRead(args[1]))
using (FileStream target = CreateForWriteAndRead(args[2]))
new Decoder(source, patch, target).Run();
Stopwatch watcher = Stopwatch.StartNew();
var decoder = new Decoder(source, patch, target);
decoder.Run();

watcher.Stop();
Console.WriteLine("Done in {0}", watcher.Elapsed);
Expand Down
4 changes: 2 additions & 2 deletions src/Pleosoft.XdeltaSharp.PerformanceTests/Adler32Tests.cs
Expand Up @@ -17,15 +17,15 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace Xdelta.PerformanceTests
namespace Pleosoft.XdeltaSharp.PerformanceTests
{
using System.IO;
using BenchmarkDotNet.Attributes;

[MemoryDiagnoser]
public class Adler32Tests
{
Stream stream;
private Stream stream;

[Params(2 * 1024, 512 * 1024, 4 * 1024 * 1024)]
public uint Length { get; set; }
Expand Down
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<Description>Performance tests of the library.</Description>
<RootNamespace>Pleosoft.XdeltaSharp.PerformanceTests</RootNamespace>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/Pleosoft.XdeltaSharp.PerformanceTests/Program.cs
Expand Up @@ -17,9 +17,8 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace Xdelta.PerformanceTests
namespace Pleosoft.XdeltaSharp.PerformanceTests
{
using System;
using BenchmarkDotNet.Running;

public static class Program
Expand Down
8 changes: 4 additions & 4 deletions src/Pleosoft.XdeltaSharp.UnitTests/Adler32Tests.cs
Expand Up @@ -17,7 +17,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace Xdelta.UnitTests
namespace Pleosoft.XdeltaSharp.UnitTests
{
using System;
using System.IO;
Expand All @@ -26,7 +26,7 @@ namespace Xdelta.UnitTests
[TestFixture]
public class Adler32Tests
{
const int NMax = 5552;
private const int NMax = 5552;

[Test]
public void Guards()
Expand Down Expand Up @@ -121,14 +121,14 @@ public void LengthLikeNMax()
[Test]
public void BiggerThanNMax()
{
using var stream = GetTestStream(NMax * 4 + 100);
using var stream = GetTestStream((NMax * 4) + 100);

uint result = Adler32.Run(stream, stream.Length);

Assert.That(result, Is.EqualTo(2570494100));
}

Stream GetTestStream(long length)
private Stream GetTestStream(long length)
{
var stream = new MemoryStream();
var data = new byte[] { 0xCA, 0xFE };
Expand Down
38 changes: 19 additions & 19 deletions src/Pleosoft.XdeltaSharp.UnitTests/DecoderTests.cs
Expand Up @@ -17,11 +17,12 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System.IO;
using NUnit.Framework;

namespace Xdelta.UnitTests
namespace Pleosoft.XdeltaSharp.UnitTests
{
using System.IO;
using NUnit.Framework;
using Pleosoft.XdeltaSharp.Decoder;

[TestFixture]
public class DecoderTests
{
Expand All @@ -30,20 +31,6 @@ public class DecoderTests
private Stream patch;
private Stream output;

private void InitWithStandardHeader()
{
input = new MemoryStream();
patch = new MemoryStream();
output = new MemoryStream();

BinaryWriter patchWriter = new BinaryWriter(patch);
patchWriter.Write(0x00C4C3D6);
patchWriter.Write((byte)0x00);
patch.Position = 0;

decoder = new Decoder(input, patch, output);
}

[TearDown]
public void TearDown()
{
Expand All @@ -66,6 +53,19 @@ public void Getters()
Assert.AreSame(patch, decoder.Patch);
Assert.AreSame(output, decoder.Output);
}

private void InitWithStandardHeader()
{
input = new MemoryStream();
patch = new MemoryStream();
output = new MemoryStream();

BinaryWriter patchWriter = new BinaryWriter(patch);
patchWriter.Write(0x00C4C3D6);
patchWriter.Write((byte)0x00);
patch.Position = 0;

decoder = new Decoder(input, patch, output);
}
}
}

42 changes: 21 additions & 21 deletions src/Pleosoft.XdeltaSharp.UnitTests/HeaderReaderTests.cs
Expand Up @@ -17,12 +17,13 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using NUnit.Framework;
using System;
using System.IO;

namespace Xdelta.UnitTests
namespace Pleosoft.XdeltaSharp.UnitTests
{
using System;
using System.IO;
using NUnit.Framework;
using Pleosoft.XdeltaSharp.Decoder;

[TestFixture]
public class HeaderReaderTests
{
Expand All @@ -35,9 +36,9 @@ public class HeaderReaderTests
[SetUp]
public void SetUp()
{
input = new MemoryStream();
input = new MemoryStream();
output = new MemoryStream();
patch = new MemoryStream();
patch = new MemoryStream();
}

[TearDown]
Expand All @@ -48,19 +49,6 @@ public void TearDown()
output.Dispose();
}

private void WriteBytes(params byte[] data)
{
patch.Write(data, 0, data.Length);
patch.Position -= data.Length;
}

private void TestThrows<T>(string message)
where T : SystemException
{
T exception = Assert.Throws<T>(() => new Decoder(input, patch, output));
Assert.AreEqual(message, exception.Message);
}

[Test]
public void InvalidStamp()
{
Expand Down Expand Up @@ -122,6 +110,18 @@ public void ReadCorrectlyApplicationData()
Decoder decoder = new Decoder(input, patch, output);
Assert.AreEqual("pleonex", decoder.Header.ApplicationData);
}

private void WriteBytes(params byte[] data)
{
patch.Write(data, 0, data.Length);
patch.Position -= data.Length;
}

private void TestThrows<T>(string message)
where T : SystemException
{
T exception = Assert.Throws<T>(() => new Decoder(input, patch, output));
Assert.AreEqual(message, exception.Message);
}
}
}

Expand Up @@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Unit tests of the library.</Description>
<RootNamespace>Pleosoft.XdeltaSharp.UnitTests</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net48;net5.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Expand Down