Skip to content

Commit 2d443db

Browse files
committed
Fixed comment of explicit conversion
1 parent f0c3849 commit 2d443db

8 files changed

+38
-11
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
5-
<VersionPrefix>8.0.2</VersionPrefix>
5+
<VersionPrefix>8.1.0</VersionPrefix>
66
<Authors>Pawel Gerr</Authors>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/KeyedValueObjectCodeGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ private void GenerateExplicitConversionToKey()
248248
/// Explicit conversion to the type ").AppendTypeForXmlComment(keyMember).Append(@".
249249
/// </summary>
250250
/// <param name=""obj"">Object to covert.</param>
251-
/// <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>
251+
/// <returns>The <see cref=""").Append(keyMember.Name).Append(@"""/> of provided <paramref name=""obj""/>.</returns>
252+
/// <exception cref=""System.NullReferenceException"">If <paramref name=""obj""/> is <c>null</c>.</exception>
252253
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull(""obj"")]
253254
public static explicit operator ").AppendTypeFullyQualified(keyMember).Append("(").AppendTypeFullyQualified(_state).Append(@" obj)
254255
{

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/Snapshots/ValueObjectSourceGeneratorTests.Should_generate_DateOnly_based_keyed_class_0.verified.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public static bool TryCreate(
103103
/// Explicit conversion to the type <see cref="global::System.DateOnly"/>.
104104
/// </summary>
105105
/// <param name="obj">Object to covert.</param>
106-
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
106+
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
107+
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
107108
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
108109
public static explicit operator global::System.DateOnly(global::Thinktecture.Tests.TestValueObject obj)
109110
{

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/Snapshots/ValueObjectSourceGeneratorTests.Should_generate_DateOnly_based_keyed_class_with_DefaultWithKeyTypeOverloads_0.verified.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public static bool TryCreate(
103103
/// Explicit conversion to the type <see cref="global::System.DateOnly"/>.
104104
/// </summary>
105105
/// <param name="obj">Object to covert.</param>
106-
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
106+
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
107+
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
107108
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
108109
public static explicit operator global::System.DateOnly(global::Thinktecture.Tests.TestValueObject obj)
109110
{

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/Snapshots/ValueObjectSourceGeneratorTests.Should_generate_int_based_keyed_class_0.verified.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public static bool TryCreate(
103103
/// Explicit conversion to the type <see cref="int"/>.
104104
/// </summary>
105105
/// <param name="obj">Object to covert.</param>
106-
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
106+
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
107+
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
107108
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
108109
public static explicit operator int(global::Thinktecture.Tests.TestValueObject obj)
109110
{

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/Snapshots/ValueObjectSourceGeneratorTests.Should_generate_int_based_keyed_class_with_DefaultWithKeyTypeOverloads_0.verified.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public static bool TryCreate(
103103
/// Explicit conversion to the type <see cref="int"/>.
104104
/// </summary>
105105
/// <param name="obj">Object to covert.</param>
106-
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
106+
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
107+
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
107108
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
108109
public static explicit operator int(global::Thinktecture.Tests.TestValueObject obj)
109110
{

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/Snapshots/ValueObjectSourceGeneratorTests.Should_not_generate_factory_methods_if_SkipFactoryMethods_is_true_0.verified.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ internal static void ModuleInit()
5454
/// Explicit conversion to the type <see cref="int"/>.
5555
/// </summary>
5656
/// <param name="obj">Object to covert.</param>
57-
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/> or <c>default</c> if <paramref name="obj"/> is <c>null</c>.</returns>
57+
/// <returns>The <see cref="_value"/> of provided <paramref name="obj"/>.</returns>
58+
/// <exception cref="System.NullReferenceException">If <paramref name="obj"/> is <c>null</c>.</exception>
5859
[return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("obj")]
5960
public static explicit operator int(global::Thinktecture.Tests.TestValueObject obj)
6061
{

test/Thinktecture.Runtime.Extensions.Tests/ValueObjectTests/ImplicitConversion.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ namespace Thinktecture.Runtime.Tests.ValueObjectTests;
55
public class ImplicitConversion
66
{
77
[Fact]
8-
public void Should_return_nullable_key_if_value_type_is_reference_type_and_key_is_struct()
8+
public void Should_return_nullable_key_if_value_object_is_reference_type_and_key_is_struct()
99
{
1010
int? value = IntBasedReferenceValueObject.Create(42);
1111
value.Should().Be(42);
1212
}
1313

1414
[Fact]
15-
public void Should_return_null_if_value_type_is_reference_type_and_null_and_key_is_struct()
15+
public void Should_return_null_if_value_object_is_reference_type_and_null_and_key_is_struct()
1616
{
1717
IntBasedReferenceValueObject obj = null;
1818
int? value = obj;
@@ -21,17 +21,38 @@ public void Should_return_null_if_value_type_is_reference_type_and_null_and_key_
2121
}
2222

2323
[Fact]
24-
public void Should_return_key_if_value_type_is_reference_type_and_key_is_reference_type()
24+
public void Should_return_key_if_value_object_is_reference_type_and_key_is_reference_type()
2525
{
2626
string value = StringBasedReferenceValueObject.Create("value");
2727
value.Should().Be("value");
2828
}
2929

3030
[Fact]
31-
public void Should_return_null_if_value_type_is_reference_type_and_null_and_key_is_reference_type()
31+
public void Should_return_null_if_value_object_is_reference_type_and_null_and_key_is_reference_type()
3232
{
3333
StringBasedReferenceValueObject obj = null;
3434
string value = obj;
3535
value.Should().BeNull();
3636
}
37+
38+
[Fact]
39+
public void Should_return_key_if_value_object_is_struct_and_key_is_struct()
40+
{
41+
int value = IntBasedStructValueObject.Create(42);
42+
value.Should().Be(42);
43+
}
44+
45+
[Fact]
46+
public void Should_return_nullable_key_if_value_object_is_nullable_struct_and_key_is_struct()
47+
{
48+
int? value = (IntBasedStructValueObject?)IntBasedStructValueObject.Create(42);
49+
value.Should().Be(42);
50+
}
51+
52+
[Fact]
53+
public void Should_return_null_if_value_object_is_nullable_struct_and_null_and_key_is_struct()
54+
{
55+
int? value = (IntBasedStructValueObject?)null;
56+
value.Should().BeNull();
57+
}
3758
}

0 commit comments

Comments
 (0)