Skip to content

Commit

Permalink
## Fixed
Browse files Browse the repository at this point in the history
- The default constructor, generated for record types when marked as partial, now applies the fully qualified type when propagating the default value, thereby removing the potential for ambiguity with the projection constructor (#8).
  • Loading branch information
MooVC committed Aug 14, 2024
1 parent 9457a2c commit 3f82f9e
Show file tree
Hide file tree
Showing 37 changed files with 464 additions and 52 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.1] - 2024-08-15

## Fixed

- The default constructor, generated for record types when marked as partial, now applies the fully qualified type when propagating the default value, thereby removing the potential for ambiguity with the projection constructor (#8).

## [1.1.0] - 2024-08-05

## Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Fluentify.Console.Class.SingleTests;

public sealed class WhenWithAgeIsCalled
{
[Fact]
public void GivenNullSubjectThenArgumentNullExceptionIsThrown()
{
// Arrange
Single? subject = default;

// Act
Func<Single> act = () => subject!.WithAge(1);

// Assert
_ = act.Should().Throw<ArgumentNullException>()
.WithParameterName(nameof(subject));
}

[Theory]
[InlineData(1)]
[InlineData(-1)]
[InlineData(0)]
[InlineData(int.MinValue)]
[InlineData(int.MaxValue)]
public void GivenAnAgeThenTheValueIsApplied(int age)
{
// Arrange
var original = new Single
{
Age = Random.Shared.Next(),
};

// Act
Single actual = original.WithAge(age);

// Assert
_ = actual.Should().NotBeSameAs(original);
_ = actual.Age.Should().Be(age);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Fluentify.Console.Record.SingleTests;

public sealed class WhenWithAgeIsCalled
{
[Fact]
public void GivenNullSubjectThenArgumentNullExceptionIsThrown()
{
// Arrange
Single? subject = default;

// Act
Func<Single> act = () => subject!.WithAge(1);

// Assert
_ = act.Should().Throw<ArgumentNullException>()
.WithParameterName(nameof(subject));
}

[Theory]
[InlineData(1)]
[InlineData(-1)]
[InlineData(0)]
[InlineData(int.MinValue)]
[InlineData(int.MaxValue)]
public void GivenAnAgeThenTheValueIsApplied(int age)
{
// Arrange
var original = new Single
{
Age = Random.Shared.Next(),
};

// Act
Single actual = original.WithAge(age);

// Assert
_ = actual.Should().NotBeSameAs(original);
_ = actual.Age.Should().Be(age);
}
}
4 changes: 2 additions & 2 deletions src/Fluentify.Console/Class/CrossReferenced.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
internal sealed class CrossReferenced
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public required string Description { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
Expand Down
10 changes: 4 additions & 6 deletions src/Fluentify.Console/Class/GlobalClass.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma warning disable SA1200 // Using directives should be placed correctly
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Fluentify;
#pragma warning restore SA1200 // Using directives should be placed correctly

/// <summary>
/// A class that demonstrates the libraries use without generics.
Expand All @@ -11,23 +9,23 @@
internal sealed class GlobalClass
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public string Name { get; init; } = string.Empty;

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
6 changes: 3 additions & 3 deletions src/Fluentify.Console/Class/MultipleGenerics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ internal sealed class MultipleGenerics<T1, T2, T3>
where T3 : IEnumerable<string>
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public required T1? Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public required T2? Name { get; init; }

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
6 changes: 3 additions & 3 deletions src/Fluentify.Console/Class/Simple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
internal sealed class Simple
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public string Name { get; init; } = string.Empty;

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
6 changes: 3 additions & 3 deletions src/Fluentify.Console/Class/SimpleWithArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
internal sealed class SimpleWithArray
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public required int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public required string Name { get; init; } = string.Empty;

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
6 changes: 3 additions & 3 deletions src/Fluentify.Console/Class/SimpleWithBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
internal sealed class SimpleWithBoolean
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public bool? IsRetired { get; init; }

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
6 changes: 3 additions & 3 deletions src/Fluentify.Console/Class/SimpleWithCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
internal sealed class SimpleWithCollection
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public required int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public required string Name { get; init; } = string.Empty;

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
10 changes: 5 additions & 5 deletions src/Fluentify.Console/Class/SimpleWithEnumerables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@
internal sealed class SimpleWithEnumerables
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public required int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public required string Name { get; init; } = string.Empty;

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
/// </value>
public required IEnumerable<object> Attributes { get; init; }

/// <summary>
/// Gets or sets the fourth property to be subject to the extension generator.
/// Gets the fourth property to be subject to the extension generator.
/// </summary>
/// <value>
/// The fourth property to be subject to the extension generator.
/// </value>
public required IReadOnlyCollection<int> Numbers { get; init; }

/// <summary>
/// Gets or sets the fifth property to be subject to the extension generator.
/// Gets the fifth property to be subject to the extension generator.
/// </summary>
/// <value>
/// The fifth property to be subject to the extension generator.
Expand Down
16 changes: 16 additions & 0 deletions src/Fluentify.Console/Class/Single.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Fluentify.Console.Class;

/// <summary>
/// A class that demonstrates the libraries use on a type with just one property.
/// </summary>
[Fluentify]
internal sealed class Single
{
/// <summary>
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public int Age { get; init; }
}
6 changes: 3 additions & 3 deletions src/Fluentify.Console/Class/SingleGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ internal sealed class SingleGeneric<T>
where T : IEnumerable
{
/// <summary>
/// Gets or sets the first property to be subject to the extension generator.
/// Gets the first property to be subject to the extension generator.
/// </summary>
/// <value>
/// The first property to be subject to the extension generator.
/// </value>
public required int Age { get; init; }

/// <summary>
/// Gets or sets the second property to be subject to the extension generator.
/// Gets the second property to be subject to the extension generator.
/// </summary>
/// <value>
/// The second property to be subject to the extension generator.
/// </value>
public required string Name { get; init; } = string.Empty;

/// <summary>
/// Gets or sets the third property to be subject to the extension generator.
/// Gets the third property to be subject to the extension generator.
/// </summary>
/// <value>
/// The third property to be subject to the extension generator.
Expand Down
8 changes: 8 additions & 0 deletions src/Fluentify.Console/Record/Single.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Fluentify.Console.Record;

/// <summary>
/// A record that demonstrates the libraries use on a type with just one property.
/// </summary>
/// <param name="Age">The first property to be subject to the extension generator.</param>
[Fluentify]
internal sealed partial record Single(int Age);
Loading

0 comments on commit 3f82f9e

Please sign in to comment.