Skip to content

Commit

Permalink
Merge pull request #14 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Version 1.8.0
  • Loading branch information
ricaun authored Sep 26, 2024
2 parents ab4f062 + 4567536 commit 3a39380
Show file tree
Hide file tree
Showing 36 changed files with 222 additions and 69 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v1
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- run: dotnet tool install --global NETFrameworkTool
- run: NETFrameworkTool --net 4.0 --install
- run: NETFrameworkTool --net 4.5 --install

- name: Run './build/build.cmd'
run: ./build/build.cmd --root ./build
env:
GitHubToken: ${{ secrets.GITHUB_TOKEN }}
SignFile: ${{ secrets.SIGN_FILE }}
SignPassword: ${{ secrets.SIGN_PASSWORD }}
NugetApiUrl: ${{ secrets.NUGET_API_URL }}
NugetApiKey: ${{ secrets.NUGET_API_KEY }}
2 changes: 1 addition & 1 deletion Build/Build.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>.</NukeRootDirectory>
Expand Down
2 changes: 1 addition & 1 deletion Build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $TempDirectory = "$PSScriptRoot\\.nuke\temp"

$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "Current"
$DotNetChannel = "LTS"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
Expand Down
2 changes: 1 addition & 1 deletion Build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"

DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="Current"
DOTNET_CHANNEL="LTS"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.8.0] / 2024-09-26
### Features
- Support `IJsonService` to use `NewtonsoftJsonService` if available.
- Release nuget [ricaun.NamedPipeWrapper.Json](https://www.nuget.org/packages/ricaun.NamedPipeWrapper.Json).
### Updated
- Update namespace to `ricaun.NamedPipeWrapper`.
- Update package to `ricaun.NamedPipeWrapper.Json`.
### Removed
- Remove `Newtonsoft.Json` reference.

## [1.7.0] / 2024-01-16
### Features
- Add `net8.0` support.
Expand Down Expand Up @@ -40,6 +50,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update `Test` project

[vNext]: ../../compare/1.5.0...HEAD
[1.8.0]: ../../compare/1.7.0...1.8.0
[1.7.0]: ../../compare/1.6.0...1.7.0
[1.6.0]: ../../compare/1.5.3...1.6.0
[1.5.3]: ../../compare/1.5.2...1.5.3
Expand Down
2 changes: 1 addition & 1 deletion ExampleCLI/MyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NamedPipeWrapper;
using ricaun.NamedPipeWrapper;

namespace ExampleCLI
{
Expand Down
2 changes: 1 addition & 1 deletion ExampleCLI/MyServer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using NamedPipeWrapper;
using ricaun.NamedPipeWrapper;

namespace ExampleCLI
{
Expand Down
2 changes: 1 addition & 1 deletion ExampleGUI/FormClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NamedPipeWrapper;
using ricaun.NamedPipeWrapper;

namespace ExampleGUI
{
Expand Down
2 changes: 1 addition & 1 deletion ExampleGUI/FormServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NamedPipeWrapper;
using ricaun.NamedPipeWrapper;

namespace ExampleGUI
{
Expand Down
1 change: 1 addition & 0 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2013 Andrew C. Dvorak <[email protected]>
Copyright (c) 2023 ricaun

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions NamedPipeWrapper/IO/PipeStreamReader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NamedPipeWrapper.Json;
using ricaun.NamedPipeWrapper.Json;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -8,7 +8,7 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace NamedPipeWrapper.IO
namespace ricaun.NamedPipeWrapper.IO
{
/// <summary>
/// Wraps a <see cref="PipeStream"/> object and reads from it. Deserializes binary data sent by a <see cref="PipeStreamWriter{T}"/>
Expand Down
2 changes: 1 addition & 1 deletion NamedPipeWrapper/IO/PipeStreamWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Runtime.Serialization;
using System.Text;

namespace NamedPipeWrapper.IO
namespace ricaun.NamedPipeWrapper.IO
{
/// <summary>
/// Wraps a <see cref="PipeStream"/> object to read and write .NET CLR objects.
Expand Down
4 changes: 2 additions & 2 deletions NamedPipeWrapper/IO/PipeStreamWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NamedPipeWrapper.Json;
using ricaun.NamedPipeWrapper.Json;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -8,7 +8,7 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace NamedPipeWrapper.IO
namespace ricaun.NamedPipeWrapper.IO
{
/// <summary>
/// Wraps a <see cref="PipeStream"/> object and writes to it. Serializes .NET CLR objects specified by <typeparamref name="T"/>
Expand Down
2 changes: 1 addition & 1 deletion NamedPipeWrapper/Json/IJsonFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;

namespace NamedPipeWrapper.Json
namespace ricaun.NamedPipeWrapper.Json
{
/// <summary>
/// IJsonFormatter
Expand Down
23 changes: 23 additions & 0 deletions NamedPipeWrapper/Json/IJsonService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace ricaun.NamedPipeWrapper.Json
{
/// <summary>
/// Represents a service for JSON serialization and deserialization.
/// </summary>
public interface IJsonService
{
/// <summary>
/// Deserializes the specified JSON string into an object of type T.
/// </summary>
/// <typeparam name="T">The type of the object to deserialize.</typeparam>
/// <param name="value">The JSON string to deserialize.</param>
/// <returns>The deserialized object of type T.</returns>
T Deserialize<T>(string value);

/// <summary>
/// Serializes the specified object into a JSON string.
/// </summary>
/// <param name="value">The object to serialize.</param>
/// <returns>The JSON string representation of the serialized object.</returns>
string Serialize(object value);
}
}
38 changes: 38 additions & 0 deletions NamedPipeWrapper/Json/Json/JsonService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace ricaun.NamedPipeWrapper.Json.Json
{
#if NETFRAMEWORK
using System.Web.Script.Serialization;
internal class JsonService : IJsonService
{
public JsonService()
{
JavaScriptSerializer = new JavaScriptSerializer();
}
public JavaScriptSerializer JavaScriptSerializer { get; set; }
public T Deserialize<T>(string value)
{
return JavaScriptSerializer.Deserialize<T>(value);
}

public string Serialize(object value)
{
return JavaScriptSerializer.Serialize(value);
}
}
#endif
#if NET
using System.Text.Json;
internal class JsonService : IJsonService
{
public T Deserialize<T>(string value)
{
return JsonSerializer.Deserialize<T>(value);
}

public string Serialize(object value)
{
return JsonSerializer.Serialize(value);
}
}
#endif
}
20 changes: 20 additions & 0 deletions NamedPipeWrapper/Json/Json/NewtonsoftJsonService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace ricaun.NamedPipeWrapper.Json.Json
{
internal class NewtonsoftJsonService : IJsonService
{
public NewtonsoftJsonService()
{
Settings = new Newtonsoft.Json.JsonSerializerSettings();
}
public Newtonsoft.Json.JsonSerializerSettings Settings { get; }
public T Deserialize<T>(string value)
{
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(value, Settings);
}

public string Serialize(object value)
{
return Newtonsoft.Json.JsonConvert.SerializeObject(value, Settings);
}
}
}
31 changes: 27 additions & 4 deletions NamedPipeWrapper/Json/JsonExtension.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
using System;
using ricaun.NamedPipeWrapper.Json.Json;
using System;

namespace NamedPipeWrapper.Json
namespace ricaun.NamedPipeWrapper.Json
{
/// <summary>
/// JsonExtension
/// </summary>
public static class JsonExtension
{
/// <summary>
/// IJsonService
/// </summary>
public static IJsonService JsonService { get; set; } = CreateJsonService();

/// <summary>
/// Create JsonService
/// </summary>
/// <returns></returns>
/// <remarks>
/// If NewtonsoftJsonService is available, use it.
/// </remarks>
private static IJsonService CreateJsonService()
{
try
{
return new NewtonsoftJsonService();
}
catch { };
return new JsonService();
}

/// <summary>
/// JsonDeserialize
/// </summary>
Expand All @@ -15,7 +38,7 @@ public static class JsonExtension
/// <returns></returns>
public static T JsonDeserialize<T>(this string value)
{
return JsonUtils.DeserializeObject<T>(value);
return JsonService.Deserialize<T>(value);
}

/// <summary>
Expand All @@ -26,7 +49,7 @@ public static T JsonDeserialize<T>(this string value)
/// <returns></returns>
public static string JsonSerialize<T>(this T value)
{
return JsonUtils.SerializeObject<T>(value);
return JsonService.Serialize(value);
}
}
}
2 changes: 1 addition & 1 deletion NamedPipeWrapper/Json/JsonFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using System.Text;

namespace NamedPipeWrapper.Json
namespace ricaun.NamedPipeWrapper.Json
{
/// <summary>
/// JsonFormatter
Expand Down
2 changes: 1 addition & 1 deletion NamedPipeWrapper/Json/JsonUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;

namespace NamedPipeWrapper.Json
namespace ricaun.NamedPipeWrapper.Json
{
/// <summary>
/// JsonUtils
Expand Down
6 changes: 3 additions & 3 deletions NamedPipeWrapper/NamedPipeClient.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using NamedPipeWrapper.IO;
using NamedPipeWrapper.Threading;
using ricaun.NamedPipeWrapper.IO;
using ricaun.NamedPipeWrapper.Threading;
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading;

namespace NamedPipeWrapper
namespace ricaun.NamedPipeWrapper
{
/// <summary>
/// Wraps a <see cref="NamedPipeClientStream"/>.
Expand Down
6 changes: 3 additions & 3 deletions NamedPipeWrapper/NamedPipeConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using NamedPipeWrapper.IO;
using NamedPipeWrapper.Threading;
using ricaun.NamedPipeWrapper.IO;
using ricaun.NamedPipeWrapper.Threading;
using System.Collections.Concurrent;

namespace NamedPipeWrapper
namespace ricaun.NamedPipeWrapper
{
/// <summary>
/// Represents a connection between a named pipe client and server.
Expand Down
6 changes: 3 additions & 3 deletions NamedPipeWrapper/NamedPipeServer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using NamedPipeWrapper.IO;
using NamedPipeWrapper.Threading;
using ricaun.NamedPipeWrapper.IO;
using ricaun.NamedPipeWrapper.Threading;
using System;
using System.Collections.Generic;
using System.IO.Pipes;

namespace NamedPipeWrapper
namespace ricaun.NamedPipeWrapper
{
/// <summary>
/// NamedPipeServer
Expand Down
4 changes: 2 additions & 2 deletions NamedPipeWrapper/NamedPipeUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NamedPipeWrapper;
using ricaun.NamedPipeWrapper;

namespace NamedPipeWrapper
namespace ricaun.NamedPipeWrapper
{
/// <summary>
/// NamedPipeUtils
Expand Down
Loading

0 comments on commit 3a39380

Please sign in to comment.