Skip to content
  •  
  •  
  •  
31 changes: 19 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.private_constant_should_be_pascal_case.severity = error
dotnet_naming_rule.private_constant_should_be_pascal_case.symbols = private_constant
dotnet_naming_rule.private_constant_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.private_constant_fields_should_be_pascal_case.severity = error
dotnet_naming_rule.private_constant_fields_should_be_pascal_case.symbols = private_constant_fields
dotnet_naming_rule.private_constant_fields_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.private_constant_fields_should_be_pascal_case.priority = 1

dotnet_naming_rule.private_static_field_should_be_camel_case.severity = error
dotnet_naming_rule.private_static_field_should_be_camel_case.symbols = private_static_field
dotnet_naming_rule.private_static_field_should_be_camel_case.style = camel_case
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.severity = error
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.style = camel_case_underscore_prefix
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.priority = 2

# Symbol specifications

Expand All @@ -197,13 +199,13 @@ dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, meth
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal
dotnet_naming_symbols.non_field_members.required_modifiers =

dotnet_naming_symbols.private_static_field.applicable_kinds = field
dotnet_naming_symbols.private_static_field.applicable_accessibilities = private
dotnet_naming_symbols.private_static_field.required_modifiers = static
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_fields.required_modifiers =

dotnet_naming_symbols.private_constant.applicable_kinds = field
dotnet_naming_symbols.private_constant.applicable_accessibilities = private
dotnet_naming_symbols.private_constant.required_modifiers = const
dotnet_naming_symbols.private_constant_fields.applicable_kinds = field
dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_constant_fields.required_modifiers = const

# Naming styles

Expand All @@ -221,6 +223,11 @@ dotnet_naming_style.camel_case.required_prefix =
dotnet_naming_style.camel_case.required_suffix =
dotnet_naming_style.camel_case.word_separator =
dotnet_naming_style.camel_case.capitalization = camel_case

dotnet_naming_style.camel_case_underscore_prefix.required_prefix = _
dotnet_naming_style.camel_case_underscore_prefix.required_suffix =
dotnet_naming_style.camel_case_underscore_prefix.word_separator =
dotnet_naming_style.camel_case_underscore_prefix.capitalization = camel_case
dotnet_diagnostic.S1117.severity = none
dotnet_diagnostic.SA1506.severity=silent
dotnet_diagnostic.SA1500.severity=error
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The project enforces strong C# coding conventions through `.editorconfig`, [Styl
- Use `var` for local variables when the type is clear from the right-hand side.
- Use `nameof` for member names in exceptions and logging.
- Use `string.Empty` instead of `""` for empty strings.
- When possible, place declarations in alphabetical order (e.g. fields, parameters, properties, methods).

### Unit Testing Conventions

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to Monify will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [1.1.3] - 2025-10-31

## Fixed
- MONFY03 is no longer raised if the encapsulated type cannot be determined (#22).
- Equality checks involing an encapsulated array containing identical values now yield true (#19).
- `ToString` no longer throws a `FormatException`.

# [1.1.2] - 2025-10-20

## Fixed
Expand Down
12 changes: 12 additions & 0 deletions Monify.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rules", "Rules", "{DF5E2435
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monify.Tests", "src\Monify.Tests\Monify.Tests.csproj", "{9C2086AB-647E-485E-A964-A4A383354230}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monify.Console", "src\Monify.Console\Monify.Console.csproj", "{8EC2148F-0491-4116-AC04-C4A0AD013C82}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monify.Console.Tests", "src\Monify.Console.Tests\Monify.Console.Tests.csproj", "{5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -79,6 +83,14 @@ Global
{9C2086AB-647E-485E-A964-A4A383354230}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C2086AB-647E-485E-A964-A4A383354230}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C2086AB-647E-485E-A964-A4A383354230}.Release|Any CPU.Build.0 = Release|Any CPU
{8EC2148F-0491-4116-AC04-C4A0AD013C82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8EC2148F-0491-4116-AC04-C4A0AD013C82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8EC2148F-0491-4116-AC04-C4A0AD013C82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8EC2148F-0491-4116-AC04-C4A0AD013C82}.Release|Any CPU.Build.0 = Release|Any CPU
{5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion build/Tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ExcludeByAttribute>GeneratedCodeAttribute</ExcludeByAttribute>
<ExcludeByAttribute>Obsolete</ExcludeByAttribute>
<ExcludeByFile>**/*.Designer.cs</ExcludeByFile>
<NoWarn>CA1859;CA1861</NoWarn>
<NoWarn>CA1859;CA1861;IDE0039</NoWarn>
<RootNamespace>$(MSBuildProjectName.Replace('.Tests', ''))</RootNamespace>
<TargetFrameworks>net9.0</TargetFrameworks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests;

public static class WhenConstructorIsCalled
{
private static readonly int[] _sampleValue = [1, 2, 3];

[Fact]
public static void GivenValueThenValueIsStored()
{
// Arrange
OutterForArray<int>.Inner instance = new(_sampleValue);

// Act
int[] actual = instance;

// Assert
actual.ShouldBe(_sampleValue);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests;

public static class WhenEqualityOperatorWithIntArrayIsCalled
{
private static readonly int[] _differentValue = [4, 5, 6];
private static readonly int[] _sampleValue = [1, 2, 3];

[Fact]
public static void GivenSubjectIsNullThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner? subject = default;

// Act
bool actual = subject == _sampleValue;

// Assert
actual.ShouldBeFalse();
}

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject == _sampleValue;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValueThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject == _differentValue;

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests;

public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled
{
private static readonly int[] _differentValue = [4, 5, 6];
private static readonly int[] _sampleValue = [1, 2, 3];

[Fact]
public static void GivenBothNullThenReturnTrue()
{
// Arrange
OutterForArray<int>.Inner? left = default;
OutterForArray<int>.Inner? right = default;

// Act
bool actual = left == right;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenLeftIsNullThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner? left = default;
OutterForArray<int>.Inner right = new(_sampleValue);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeFalse();
}

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForArray<int>.Inner left = new(_sampleValue);
OutterForArray<int>.Inner right = new(_sampleValue);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenEquivalentValuesThenReturnTrue()
{
// Arrange
int[] leftValues = [1, 2, 3];
int[] rightValues = [1, 2, 3];
OutterForArray<int>.Inner left = new(leftValues);
OutterForArray<int>.Inner right = new(rightValues);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValuesThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner left = new(_sampleValue);
OutterForArray<int>.Inner right = new(_differentValue);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests;

public static class WhenEqualsWithIntArrayIsCalled
{
private static readonly int[] _differentValue = [4, 5, 6];
private static readonly int[] _sampleValue = [1, 2, 3];

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject.Equals(_sampleValue);

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValueThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject.Equals(_differentValue);

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests;

public static class WhenEqualsWithObjectIsCalled
{
private static readonly int[] _sampleValue = [1, 2, 3];

[Fact]
public static void GivenNullThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject.Equals((object?)default);

// Assert
actual.ShouldBeFalse();
}

[Fact]
public static void GivenEquivalentOutterForArrayInnerThenReturnTrue()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);
object other = new OutterForArray<int>.Inner(_sampleValue);

// Act
bool actual = subject.Equals(other);

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentTypeThenThrowInvalidCastException()
{
// Arrange
OutterForArray<int>.Inner subject = new(_sampleValue);
object other = string.Empty;

// Act
Action act = () => subject.Equals(other);

// Assert
_ = Should.Throw<InvalidCastException>(act);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests;

public static class WhenEqualsWithOutterForArrayInnerIsCalled
{
private static readonly int[] _differentValue = [4, 5, 6];
private static readonly int[] _sampleValue = [1, 2, 3];

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForArray<int>.Inner left = new(_sampleValue);
OutterForArray<int>.Inner right = new(_sampleValue);

// Act
bool actual = left.Equals(right);

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValueThenReturnFalse()
{
// Arrange
OutterForArray<int>.Inner left = new(_sampleValue);
OutterForArray<int>.Inner right = new(_differentValue);

// Act
bool actual = left.Equals(right);

// Assert
actual.ShouldBeFalse();
}
}
Loading