Skip to content

Commit

Permalink
Fixed comment of explicit conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelGerr committed Jan 17, 2025
1 parent f0c3849 commit 2d443db
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
<VersionPrefix>8.0.2</VersionPrefix>
<VersionPrefix>8.1.0</VersionPrefix>
<Authors>Pawel Gerr</Authors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ private void GenerateExplicitConversionToKey()
/// Explicit conversion to the type ").AppendTypeForXmlComment(keyMember).Append(@".
/// </summary>
/// <param name=""obj"">Object to covert.</param>
/// <returns>The <see cref=""").Append(keyMember.Name).Append(@"""/> of provided <paramref name=""obj""/> or <c>default</c> if <paramref name=""obj""/> is <c>null</c>.</returns>
/// <returns>The <see cref=""").Append(keyMember.Name).Append(@"""/> of provided <paramref name=""obj""/>.</returns>
/// <exception cref=""System.NullReferenceException"">If <paramref name=""obj""/> is <c>null</c>.</exception>
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""obj"")]
public static explicit operator ").AppendTypeFullyQualified(keyMember).Append("(").AppendTypeFullyQualified(_state).Append(@" obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public static bool TryCreate(
/// Explicit conversion to the type <see cref="global::System.DateOnly"/>.
/// </summary>
/// <param name="obj">Object to covert.</param>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
public static explicit operator global::System.DateOnly(global::Thinktecture.Tests.TestValueObject obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public static bool TryCreate(
/// Explicit conversion to the type <see cref="global::System.DateOnly"/>.
/// </summary>
/// <param name="obj">Object to covert.</param>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
public static explicit operator global::System.DateOnly(global::Thinktecture.Tests.TestValueObject obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public static bool TryCreate(
/// Explicit conversion to the type <see cref="int"/>.
/// </summary>
/// <param name="obj">Object to covert.</param>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
public static explicit operator int(global::Thinktecture.Tests.TestValueObject obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public static bool TryCreate(
/// Explicit conversion to the type <see cref="int"/>.
/// </summary>
/// <param name="obj">Object to covert.</param>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
public static explicit operator int(global::Thinktecture.Tests.TestValueObject obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ internal static void ModuleInit()
/// Explicit conversion to the type <see cref="int"/>.
/// </summary>
/// <param name="obj">Object to covert.</param>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
public static explicit operator int(global::Thinktecture.Tests.TestValueObject obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace Thinktecture.Runtime.Tests.ValueObjectTests;
public class ImplicitConversion
{
[Fact]
public void Should_return_nullable_key_if_value_type_is_reference_type_and_key_is_struct()
public void Should_return_nullable_key_if_value_object_is_reference_type_and_key_is_struct()
{
int? value = IntBasedReferenceValueObject.Create(42);
value.Should().Be(42);
}

[Fact]
public void Should_return_null_if_value_type_is_reference_type_and_null_and_key_is_struct()
public void Should_return_null_if_value_object_is_reference_type_and_null_and_key_is_struct()
{
IntBasedReferenceValueObject obj = null;
int? value = obj;
Expand All @@ -21,17 +21,38 @@ public void Should_return_null_if_value_type_is_reference_type_and_null_and_key_
}

[Fact]
public void Should_return_key_if_value_type_is_reference_type_and_key_is_reference_type()
public void Should_return_key_if_value_object_is_reference_type_and_key_is_reference_type()
{
string value = StringBasedReferenceValueObject.Create("value");
value.Should().Be("value");
}

[Fact]
public void Should_return_null_if_value_type_is_reference_type_and_null_and_key_is_reference_type()
public void Should_return_null_if_value_object_is_reference_type_and_null_and_key_is_reference_type()
{
StringBasedReferenceValueObject obj = null;
string value = obj;
value.Should().BeNull();
}

[Fact]
public void Should_return_key_if_value_object_is_struct_and_key_is_struct()
{
int value = IntBasedStructValueObject.Create(42);
value.Should().Be(42);
}

[Fact]
public void Should_return_nullable_key_if_value_object_is_nullable_struct_and_key_is_struct()
{
int? value = (IntBasedStructValueObject?)IntBasedStructValueObject.Create(42);
value.Should().Be(42);
}

[Fact]
public void Should_return_null_if_value_object_is_nullable_struct_and_null_and_key_is_struct()
{
int? value = (IntBasedStructValueObject?)null;
value.Should().BeNull();
}
}

0 comments on commit 2d443db

Please sign in to comment.