Skip to content

Commit

Permalink
Merge pull request #110 from meyerhenning/feature/access_refactoring
Browse files Browse the repository at this point in the history
Refactoring: Modifier Order & Access To Properties
  • Loading branch information
BenMorris authored Apr 7, 2023
2 parents 9f1076c + d1689b8 commit 221e717
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NetArchTest.Rules.Extensions
/// <summary>
/// Extensions for the <see cref="FieldDefinition"/> class.
/// </summary>
static internal class FieldDefinitionExtensions
internal static class FieldDefinitionExtensions
{
/// <summary>
/// Tests whether a field is readonly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NetArchTest.Rules.Extensions
/// <summary>
/// Extensions for the <see cref="PropertyDefinition"/> class.
/// </summary>
static internal class PropertyDefinitionExtensions
internal static class PropertyDefinitionExtensions
{
/// <summary>
/// Tests whether a property is readonly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// <summary>
/// Extensions for the <see cref="TypeDefinition"/> class.
/// </summary>
static internal class TypeDefinitionExtensions
internal static class TypeDefinitionExtensions
{
/// <summary>
/// Tests whether one class inherits from another.
Expand Down
2 changes: 1 addition & 1 deletion src/NetArchTest.Rules/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// <summary>
/// Extensions for the <see cref="Type"/> class.
/// </summary>
static internal class TypeExtensions
internal static class TypeExtensions
{
/// <summary>
/// Converts the value to a <see cref="TypeDefinition"/> instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace NetArchTest.Rules.Extensions
using System.Collections.Generic;
using Mono.Cecil;

static internal class TypeReferenceExtensions
internal static class TypeReferenceExtensions
{
/// <summary>
/// Tests whether a Type is a non-nullable value type
Expand Down
4 changes: 2 additions & 2 deletions src/NetArchTest.Rules/Policies/Policy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
public sealed class Policy
{
/// <summary> The simple name of the policy. </summary>
private string _name;
private readonly string _name;

/// <summary> A detailed description of the policy. </summary>
private string _description;
private readonly string _description;

/// <summary>
/// Initializes a new instance of the <see cref="Policy"/> class.
Expand Down
8 changes: 4 additions & 4 deletions src/NetArchTest.Rules/Policies/PolicyDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
public sealed class PolicyDefinition
{
/// <summary> The function that defines the list of types to execute against each rule. </summary>
private Func<Types> _typesLocator;
private readonly Func<Types> _typesLocator;

/// <summary> The list of tests that have been added to the policy. </summary>
private List<PolicyTest> _tests = new List<PolicyTest>();
private readonly List<PolicyTest> _tests = new List<PolicyTest>();

/// <summary>
/// Initializes a new instance of the <see cref="PolicyDefinition"/> class.
Expand All @@ -28,12 +28,12 @@ internal PolicyDefinition(Func<Types> types, string name, string description)
/// <summary>
/// The simple name of the policy.
/// </summary>
public string Name { get; private set; }
public string Name { get; }

/// <summary>
/// A detailed description of the policy.
/// </summary>
public string Description { get; private set; }
public string Description { get; }

/// <summary>
/// Adds a rule to the policy that can optionally be marked with a name and description.
Expand Down
8 changes: 4 additions & 4 deletions src/NetArchTest.Rules/Policies/PolicyResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ internal PolicyResult(TestResult result, string name, string description)
/// <summary>
/// Gets a flag indicating the success or failure of the test.
/// </summary>
public bool IsSuccessful { get; private set; }
public bool IsSuccessful { get; }

/// <summary>
/// Gets a collection populated with a list of any types that failed the test.
/// </summary>
public IEnumerable<Type> FailingTypes { get; private set; }
public IEnumerable<Type> FailingTypes { get; }

/// <summary>
/// Gets the simple name associated with the test.
/// </summary>
public string Name { get; private set; }
public string Name { get; }

/// <summary>
/// Gets the detailed description associated with the test.
/// </summary>
public string Description { get; private set; }
public string Description { get; }
}
}
13 changes: 4 additions & 9 deletions src/NetArchTest.Rules/Policies/PolicyResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@ internal PolicyResults(IReadOnlyList<PolicyResult> results, string name, string
/// Gets whether or not the policy has any rule violations
/// </summary>
public bool HasViolations
{
get
{
return Results.Any(r => !r.IsSuccessful);
}
}
=> Results.Any(r => !r.IsSuccessful);

/// <summary>
/// Gets the results of each rule that was added the policy.
/// </summary>
public IReadOnlyList<PolicyResult> Results { get; private set; }
public IReadOnlyList<PolicyResult> Results { get; }

/// <summary>
/// Gets the simple name associated with the policy.
/// </summary>
public string Name { get; private set; }
public string Name { get; }

/// <summary>
/// Gets the detailed description associated with the policy.
/// </summary>
public string Description { get; private set; }
public string Description { get; }

}
}
6 changes: 3 additions & 3 deletions src/NetArchTest.Rules/Policies/PolicyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ internal PolicyTest(Func<Types, ConditionList> definition, string name, string d
/// <summary>
/// The definition of the test expressed as a function.
/// </summary>
internal Func<Types, ConditionList> Definition { get; private set; }
internal Func<Types, ConditionList> Definition { get; }

/// <summary>
/// Gets the simple name associated with the test.
/// </summary>
internal string Name { get; private set; }
internal string Name { get; }

/// <summary>
/// Gets the detailed description associated with the test.
/// </summary>
internal string Description { get; private set; }
internal string Description { get; }
}
}

0 comments on commit 221e717

Please sign in to comment.