-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Nyris.CodeAnalysis.CSharp.CodeStyle to 0.5.0
- Loading branch information
1 parent
a1ca461
commit 835935e
Showing
164 changed files
with
4,935 additions
and
5,026 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
namespace Node1 | ||
namespace Node1; | ||
|
||
internal static class Program | ||
{ | ||
internal static class Program | ||
public static void Main(string[] args) | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Nyris.Crdt.AspNetExample.Program.Main(args); | ||
} | ||
Nyris.Crdt.AspNetExample.Program.Main(args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
namespace Node2 | ||
namespace Node2; | ||
|
||
internal static class Program | ||
{ | ||
internal static class Program | ||
public static void Main(string[] args) | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Nyris.Crdt.AspNetExample.Program.Main(args); | ||
} | ||
Nyris.Crdt.AspNetExample.Program.Main(args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,105 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Newtonsoft.Json; | ||
using Nyris.Crdt.Distributed.Model.Converters; | ||
using Nyris.Crdt.Model; | ||
using ProtoBuf; | ||
using System; | ||
using System.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Nyris.Crdt.AspNetExample; | ||
|
||
namespace Nyris.Crdt.AspNetExample | ||
/// <summary> | ||
/// Encapsulates Guid | ||
/// </summary> | ||
[JsonConverter(typeof(InternalIdJsonConverter<CollectionId, Factory>))] | ||
[TypeConverter(typeof(InternalIdTypeConverter<CollectionId, Factory>))] | ||
[ProtoContract] | ||
public readonly struct CollectionId : IEquatable<CollectionId>, IFormattable, IComparable<CollectionId>, IAs<Guid>, | ||
IHashable | ||
{ | ||
/// <summary> | ||
/// Encapsulates Guid | ||
/// Converts guid into NodeId. | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
[ProtoConverter] | ||
public static CollectionId FromGuid(Guid id) => new(id); | ||
|
||
/// <summary> | ||
/// Generates new random Id. | ||
/// </summary> | ||
/// <returns></returns> | ||
public static CollectionId New() => new(Guid.NewGuid()); | ||
|
||
/// <summary> | ||
/// Converts the string representation of an NodeId to the equivalent NodeId structure. | ||
/// </summary> | ||
/// <param name="input">input – The string to convert.</param> | ||
/// <returns></returns> | ||
public static CollectionId Parse(string input) => new(Guid.Parse(input)); | ||
|
||
/// <summary> | ||
/// A read-only instance of the NodeId structure, that can represent default or uninitialized value. | ||
/// </summary> | ||
[JsonConverter(typeof(InternalIdJsonConverter<CollectionId, Factory>))] | ||
[TypeConverter(typeof(InternalIdTypeConverter<CollectionId, Factory>))] | ||
[ProtoContract] | ||
public readonly struct CollectionId : IEquatable<CollectionId>, IFormattable, IComparable<CollectionId>, IAs<Guid>, | ||
IHashable | ||
public static readonly CollectionId Empty = new(Guid.Empty); | ||
|
||
/// <summary> | ||
/// Converts the string representation of an NodeId to the equivalent NodeId structure. | ||
/// </summary> | ||
/// <param name="input">A string containing the NodeId to convert</param> | ||
/// <param name="collectionId">An NodeId instance to contain the parsed value. If the method returns true, | ||
/// result contains a valid NodeId. If the method returns false, result equals Empty.</param> | ||
/// <returns>true if the parse operation was successful; otherwise, false.</returns> | ||
public static bool TryParse(string input, [NotNullWhen(true)] out CollectionId collectionId) | ||
{ | ||
/// <summary> | ||
/// Converts guid into NodeId. | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <returns></returns> | ||
[ProtoConverter] | ||
public static CollectionId FromGuid(Guid id) => new(id); | ||
|
||
/// <summary> | ||
/// Generates new random Id. | ||
/// </summary> | ||
/// <returns></returns> | ||
public static CollectionId New() => new(Guid.NewGuid()); | ||
|
||
/// <summary> | ||
/// Converts the string representation of an NodeId to the equivalent NodeId structure. | ||
/// </summary> | ||
/// <param name="input">input – The string to convert.</param> | ||
/// <returns></returns> | ||
public static CollectionId Parse(string input) => new(Guid.Parse(input)); | ||
|
||
/// <summary> | ||
/// A read-only instance of the NodeId structure, that can represent default or uninitialized value. | ||
/// </summary> | ||
public static readonly CollectionId Empty = new(Guid.Empty); | ||
|
||
/// <summary> | ||
/// Converts the string representation of an NodeId to the equivalent NodeId structure. | ||
/// </summary> | ||
/// <param name="input">A string containing the NodeId to convert</param> | ||
/// <param name="collectionId">An NodeId instance to contain the parsed value. If the method returns true, | ||
/// result contains a valid NodeId. If the method returns false, result equals Empty.</param> | ||
/// <returns>true if the parse operation was successful; otherwise, false.</returns> | ||
public static bool TryParse(string input, [NotNullWhen(true)] out CollectionId collectionId) | ||
if (Guid.TryParse(input, out var guid)) | ||
{ | ||
if (Guid.TryParse(input, out var guid)) | ||
{ | ||
collectionId = FromGuid(guid); | ||
return true; | ||
} | ||
|
||
collectionId = Empty; | ||
return false; | ||
collectionId = FromGuid(guid); | ||
return true; | ||
} | ||
|
||
[ProtoMember(1)] private readonly Guid _id; | ||
collectionId = Empty; | ||
return false; | ||
} | ||
|
||
private CollectionId(Guid id) | ||
{ | ||
_id = id; | ||
} | ||
[ProtoMember(1)] private readonly Guid _id; | ||
|
||
/// <inheritdoc /> | ||
public Guid Value => _id; | ||
private CollectionId(Guid id) | ||
{ | ||
_id = id; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public bool Equals(CollectionId other) => _id.Equals(other._id); | ||
/// <inheritdoc /> | ||
public Guid Value => _id; | ||
|
||
/// <inheritdoc /> | ||
public override bool Equals(object? obj) => obj is CollectionId other && Equals(other); | ||
/// <inheritdoc /> | ||
public bool Equals(CollectionId other) => _id.Equals(other._id); | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() => _id.GetHashCode(); | ||
/// <inheritdoc /> | ||
public override bool Equals(object? obj) => obj is CollectionId other && Equals(other); | ||
|
||
/// <inheritdoc /> | ||
public string ToString(string? format, IFormatProvider? formatProvider) => _id.ToString(format, formatProvider); | ||
/// <inheritdoc /> | ||
public override int GetHashCode() => _id.GetHashCode(); | ||
|
||
/// <inheritdoc /> | ||
public override string ToString() => _id.ToString("N"); | ||
/// <inheritdoc /> | ||
public string ToString(string? format, IFormatProvider? formatProvider) => _id.ToString(format, formatProvider); | ||
|
||
/// <inheritdoc /> | ||
public ReadOnlySpan<byte> CalculateHash() => _id.ToByteArray(); | ||
/// <inheritdoc /> | ||
public override string ToString() => _id.ToString("N"); | ||
|
||
/// <inheritdoc /> | ||
public int CompareTo(CollectionId other) => _id.CompareTo(other._id); | ||
/// <inheritdoc /> | ||
public ReadOnlySpan<byte> CalculateHash() => _id.ToByteArray(); | ||
|
||
public static bool operator ==(CollectionId left, CollectionId right) => left.Equals(right); | ||
/// <inheritdoc /> | ||
public int CompareTo(CollectionId other) => _id.CompareTo(other._id); | ||
|
||
public static bool operator !=(CollectionId left, CollectionId right) => !(left == right); | ||
public static bool operator ==(CollectionId left, CollectionId right) => left.Equals(right); | ||
|
||
private class Factory : IFactory<CollectionId> | ||
{ | ||
CollectionId IFactory<CollectionId>.Empty => Empty; | ||
CollectionId IFactory<CollectionId>.Parse(string value) => CollectionId.Parse(value); | ||
} | ||
public static bool operator !=(CollectionId left, CollectionId right) => !(left == right); | ||
|
||
private class Factory : IFactory<CollectionId> | ||
{ | ||
CollectionId IFactory<CollectionId>.Empty => Empty; | ||
CollectionId IFactory<CollectionId>.Parse(string value) => CollectionId.Parse(value); | ||
} | ||
} |
29 changes: 14 additions & 15 deletions
29
samples/Nyris.Crdt.AspNetExample/Controllers/HomeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Nyris.Crdt.Distributed.Model; | ||
|
||
namespace Nyris.Crdt.AspNetExample.Controllers | ||
namespace Nyris.Crdt.AspNetExample.Controllers; | ||
|
||
[ApiController] | ||
[Route("/")] | ||
public class HomeController : ControllerBase | ||
{ | ||
[ApiController] | ||
[Route("/")] | ||
public class HomeController: ControllerBase | ||
{ | ||
private readonly NodeId _thisNodeId; | ||
private readonly NodeId _thisNodeId; | ||
|
||
public HomeController(NodeInfo nodeInfo) | ||
{ | ||
_thisNodeId = nodeInfo.Id; | ||
} | ||
public HomeController(NodeInfo nodeInfo) | ||
{ | ||
_thisNodeId = nodeInfo.Id; | ||
} | ||
|
||
[HttpGet] | ||
public IActionResult Index() | ||
{ | ||
return Ok(_thisNodeId); | ||
} | ||
[HttpGet] | ||
public IActionResult Index() | ||
{ | ||
return Ok(_thisNodeId); | ||
} | ||
} |
Oops, something went wrong.