Skip to content

Commit

Permalink
fix: merge conflicts from 1.4.18 hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
dtanglr committed Mar 30, 2024
2 parents 09e237e + 13026ae commit c7819ee
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 201 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<PackageOutputPath>$(MSBuildThisFileDirectory)..\artifacts</PackageOutputPath>
<version>1.5.0-alpha.14</version>
<version>1.5.0-alpha.15</version>
</PropertyGroup>

<ItemGroup>
Expand Down
26 changes: 14 additions & 12 deletions src/Primitively/EmbeddedResources/Numeric/Base.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
readonly partial record struct PRIMITIVE_TYPE : global::PRIMITIVE_INTERFACE, global::System.IEquatable<PRIMITIVE_TYPE>, global::System.IComparable<PRIMITIVE_TYPE>PRIMITIVE_IVALIDATABLEOBJECT
{
private readonly global::PRIMITIVE_VALUE_TYPE _value;
private readonly global::PRIMITIVE_VALUE_TYPE _value = default;

public const string Example = "PRIMITIVE_EXAMPLE";
public const global::PRIMITIVE_VALUE_TYPE Minimum = PRIMITIVE_MINIMUM;
public const global::PRIMITIVE_VALUE_TYPE Maximum = PRIMITIVE_MAXIMUM;

public PRIMITIVE_TYPE()
{
HasValue = IsMatch(_value);
_value = default;
}

public PRIMITIVE_TYPE(global::PRIMITIVE_VALUE_TYPE value)
{
if (value >= Minimum && value <= Maximum)
{
_value = value;
HasValue = true;
}
HasValue = IsMatch(value);
_value = HasValue ? value : default;
}

private PRIMITIVE_TYPE(string value)
{
if (global::PRIMITIVE_VALUE_TYPE.TryParse(value, out var result) && result >= Minimum && result <= Maximum)
{
_value = result;
HasValue = true;
}
HasValue = global::PRIMITIVE_VALUE_TYPE.TryParse(value, out var result) && IsMatch(result);
_value = HasValue ? result : default;
}

object global::Primitively.IPrimitive.Value => _value;

global::PRIMITIVE_VALUE_TYPE global::Primitively.IPrimitive<global::PRIMITIVE_VALUE_TYPE>.Value => _value;

[global::System.Text.Json.Serialization.JsonIgnore]
public bool HasValue { get; }
public bool HasValue { get; } = false;

[global::System.Text.Json.Serialization.JsonIgnore]
public global::System.Type ValueType => typeof(global::PRIMITIVE_VALUE_TYPE);
Expand All @@ -49,3 +49,5 @@ private PRIMITIVE_TYPE(string value)

public static PRIMITIVE_TYPE Parse(string value) => new(value);
public static bool TryParse(string value, out PRIMITIVE_TYPE result) => (result = new(value)).HasValue;

private static bool IsMatch(global::PRIMITIVE_VALUE_TYPE value) => value >= Minimum && value <= Maximum;
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1")]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(ByteId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1")]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ByteId.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
var expectedInteger = hasValue ? ByteId.Parse(from) : default;
var expectedString = expectedInteger.ToString();

var @this = (ByteId)from;
string to = @this;
var that = ByteId.Parse(to);
var and = new ByteId(that);
string back = and;
var @this = ByteId.Parse(from);

@this.HasValue.Should().Be(hasValue);
@this.Should().Be(expectedInteger);
@this.ToString().Should().Be(expectedString);
to.Should().Be(expectedString);
that.HasValue.Should().Be(hasValue);
that.Should().Be(expectedInteger);
that.ToString().Should().Be(expectedString);
and.HasValue.Should().Be(hasValue);
and.Should().Be(expectedInteger);
and.ToString().Should().Be(expectedString);
back.Should().Be(expectedString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true, true)]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(IntId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true)]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(IntId.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
var expectedInteger = hasValue ? IntId.Parse(from) : default;
var expectedString = expectedInteger.ToString();

var @this = (IntId)from;
string to = @this;
var that = IntId.Parse(to);
var and = new IntId(that);
string back = and;
var @this = IntId.Parse(from);

@this.HasValue.Should().Be(hasValue);
@this.Should().Be(expectedInteger);
@this.ToString().Should().Be(expectedString);
to.Should().Be(expectedString);
that.HasValue.Should().Be(hasValue);
that.Should().Be(expectedInteger);
that.ToString().Should().Be(expectedString);
and.HasValue.Should().Be(hasValue);
and.Should().Be(expectedInteger);
and.ToString().Should().Be(expectedString);
back.Should().Be(expectedString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ public class ValidateMethodTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true)]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ValidatableInteger.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool isValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true, true)]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(LongId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true)]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(LongId.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
var expectedInteger = hasValue ? LongId.Parse(from) : default;
var expectedString = expectedInteger.ToString();

var @this = (LongId)from;
string to = @this;
var that = LongId.Parse(to);
var and = new LongId(that);
string back = and;
var @this = LongId.Parse(from);

@this.HasValue.Should().Be(hasValue);
@this.Should().Be(expectedInteger);
@this.ToString().Should().Be(expectedString);
to.Should().Be(expectedString);
that.HasValue.Should().Be(hasValue);
that.Should().Be(expectedInteger);
that.ToString().Should().Be(expectedString);
and.HasValue.Should().Be(hasValue);
and.Should().Be(expectedInteger);
and.ToString().Should().Be(expectedString);
back.Should().Be(expectedString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true, true)]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(SByteId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true)]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(SByteId.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
var expectedInteger = hasValue ? SByteId.Parse(from) : default;
var expectedString = expectedInteger.ToString();

var @this = (SByteId)from;
string to = @this;
var that = SByteId.Parse(to);
var and = new SByteId(that);
string back = and;
var @this = SByteId.Parse(from);

@this.HasValue.Should().Be(hasValue);
@this.Should().Be(expectedInteger);
@this.ToString().Should().Be(expectedString);
to.Should().Be(expectedString);
that.HasValue.Should().Be(hasValue);
that.Should().Be(expectedInteger);
that.ToString().Should().Be(expectedString);
and.HasValue.Should().Be(hasValue);
and.Should().Be(expectedInteger);
and.ToString().Should().Be(expectedString);
back.Should().Be(expectedString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true, true)]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(ShortId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1", true)]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ShortId.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
var expectedInteger = hasValue ? ShortId.Parse(from) : default;
var expectedString = expectedInteger.ToString();

var @this = (ShortId)from;
string to = @this;
var that = ShortId.Parse(to);
var and = new ShortId(that);
string back = and;
var @this = ShortId.Parse(from);

@this.HasValue.Should().Be(hasValue);
@this.Should().Be(expectedInteger);
@this.ToString().Should().Be(expectedString);
to.Should().Be(expectedString);
that.HasValue.Should().Be(hasValue);
that.Should().Be(expectedInteger);
that.ToString().Should().Be(expectedString);
and.HasValue.Should().Be(hasValue);
and.Should().Be(expectedInteger);
and.ToString().Should().Be(expectedString);
back.Should().Be(expectedString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1")]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(UIntId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1")]
[InlineData("0", true)]
[InlineData("00", true)]
[InlineData("001", true)]
[InlineData(UIntId.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
var expectedInteger = hasValue ? UIntId.Parse(from) : default;
var expectedString = expectedInteger.ToString();

var @this = (UIntId)from;
string to = @this;
var that = UIntId.Parse(to);
var and = new UIntId(that);
string back = and;
var @this = UIntId.Parse(from);

@this.HasValue.Should().Be(hasValue);
@this.Should().Be(expectedInteger);
@this.ToString().Should().Be(expectedString);
to.Should().Be(expectedString);
that.HasValue.Should().Be(hasValue);
that.Should().Be(expectedInteger);
that.ToString().Should().Be(expectedString);
and.HasValue.Should().Be(hasValue);
and.Should().Be(expectedInteger);
and.ToString().Should().Be(expectedString);
back.Should().Be(expectedString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
[InlineData("0")]
[InlineData("00")]
[InlineData("-1")]
[InlineData("0", true, true)]
[InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(ULongId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
Expand Down
Loading

0 comments on commit c7819ee

Please sign in to comment.