Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek-galezowski committed Jul 17, 2024
1 parent 6b25f2c commit 26a0daa
Show file tree
Hide file tree
Showing 42 changed files with 122 additions and 130 deletions.
16 changes: 15 additions & 1 deletion src/netstandard2.0/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 2
dotnet_diagnostic.CA1859.severity = silent
dotnet_diagnostic.CA1860.severity = silent
dotnet_diagnostic.CA1822.severity = silent
###############################
# C# Coding Conventions #
###############################
Expand Down Expand Up @@ -115,6 +120,15 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_prefer_static_local_function = true:suggestion
###############################
# VB Coding Conventions #
###############################
Expand Down
2 changes: 1 addition & 1 deletion src/netstandard2.0/Any.v3.ncrunchsolution
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<SolutionConfiguration>
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<EnableRDI>True</EnableRDI>
<EnableRDI>False</EnableRDI>
<RdiConfigured>True</RdiConfigured>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<AssemblyName>TddXt.Any.Extensibility</AssemblyName>
<RootNamespace>TddXt.AnyExtensibility</RootNamespace>
<Authors>Grzegorz Gałęzowski</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/netstandard2.0/AnyGenerators/AnyGenerators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<AssemblyName>TddXt.Any.Generators</AssemblyName>
<RootNamespace>TddXt.AnyGenerators</RootNamespace>
<Authors>Grzegorz Gałęzowski</Authors>
Expand Down
5 changes: 3 additions & 2 deletions src/netstandard2.0/AnyRoot/AnyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace TddXt.AnyRoot;

public static class AnyExtensions
{
private static readonly Type[] ValueTypes = {
private static readonly Type[] ValueTypes =
[
typeof(byte),
typeof(short),
typeof(ushort),
Expand All @@ -24,7 +25,7 @@ public static class AnyExtensions
typeof(char),
typeof(object),
typeof(string)
};
];

public static T From<T>(this BasicGenerator gen, params T[] possibleValues)
{
Expand Down
2 changes: 1 addition & 1 deletion src/netstandard2.0/AnyRoot/AnyRoot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<AssemblyName>TddXt.Any.Root</AssemblyName>
<RootNamespace>TddXt.AnyRoot</RootNamespace>
<PackageId>Any</PackageId>
Expand Down
3 changes: 1 addition & 2 deletions src/netstandard2.0/AnyRoot/Builder/BuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public static T WithProperty<T, TValue>(this T target, Expression<Func<T, TValue

private static object TargetParentObject(object target, MemberExpression memberSelectorExpression)
{
var parentExpression = memberSelectorExpression.Expression as MemberExpression;
if (parentExpression == null)
if (memberSelectorExpression.Expression is not MemberExpression parentExpression)
{
return target;
}
Expand Down
13 changes: 8 additions & 5 deletions src/netstandard2.0/AnySpecification/AnySpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

namespace AnySpecification;

public class AnySpecification
public partial class AnySpecification
{
[Test, Parallelizable]
public void ShouldGenerateDifferentIntegerEachTime()
Expand Down Expand Up @@ -462,7 +462,7 @@ public void ShouldGenerateStringAccordingtoRegex()
var result = Any.StringMatching(exampleRegex);

//THEN
ClassicAssert.True(Regex.IsMatch(result, exampleRegex));
ClassicAssert.True(ExampleRegex().IsMatch(result));
}

[TestCase(2)]
Expand Down Expand Up @@ -1516,7 +1516,7 @@ public void ShouldAllowGeneratingDummyImmutableArrays()

//THEN
ClassicAssert.NotNull(readOnlyList);
ClassicAssert.AreEqual(0, readOnlyList.Count());
ClassicAssert.AreEqual(0, readOnlyList.Length);
}

[Test, Parallelizable, Ignore("diminishing disabled for now for backwards compatibility reasons")]
Expand Down Expand Up @@ -1680,7 +1680,7 @@ public void ShouldAllowGeneratingImmutableSortedSets()

//THEN
ClassicAssert.NotNull(collection);
ClassicAssert.AreEqual(3, collection.Count());
ClassicAssert.AreEqual(3, collection.Count);
CollectionAssert.AllItemsAreNotNull(collection);
CollectionAssert.AllItemsAreUnique(collection);
}
Expand All @@ -1694,7 +1694,7 @@ public void ShouldAllowGeneratingDummyImmutableSortedSets()

//THEN
ClassicAssert.NotNull(collection);
ClassicAssert.AreEqual(0, collection.Count());
ClassicAssert.AreEqual(0, collection.Count);
}

[Test, Parallelizable]
Expand Down Expand Up @@ -1938,4 +1938,7 @@ private static void NotAlike<T>(T expected, T actual)
var result = comparison.Compare(expected, actual);
result.ExceededDifferences.Should().BeTrue(result.DifferencesString);
}

[GeneratedRegex(@"content/([A-Za-z0-9\-]+)\.aspx$")]
private static partial Regex ExampleRegex();
}
9 changes: 2 additions & 7 deletions src/netstandard2.0/AnySpecification/BuilderSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,9 @@ public void ShouldAllowSettingPropertyThroughPublicField()
}
}

public class DataStructure
public class DataStructure(NestedDataStructure nested)
{
public DataStructure(NestedDataStructure nested)
{
Nested = nested;
}

public NestedDataStructure? Nested { get; }
public NestedDataStructure? Nested { get; } = nested;
public NestedDataStructure? NestedField;
public NestedDataStructure? NestedReadOnlyField;
public NestedDataStructure? NestedNotInitializedFromConstructor { get; }
Expand Down
17 changes: 17 additions & 0 deletions src/netstandard2.0/BuildScript/ConsoleOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using NScan.SharedKernel.WritingProgramOutput.Ports;

namespace BuildScript;

public class ConsoleOutput : INScanOutput
{
public void WriteAnalysisReport(string analysisReport)
{
Console.WriteLine(analysisReport);
}

public void WriteVersion(string coreVersion)
{
Console.WriteLine(coreVersion);
}
}
16 changes: 1 addition & 15 deletions src/netstandard2.0/BuildScript/Script.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using AtmaFileSystem;
using AtmaFileSystem.IO;
using BuildScript;
using FluentAssertions;
using NScan.Adapters.Secondary.NotifyingSupport;
using NScan.SharedKernel.WritingProgramOutput.Ports;
using TddXt.NScan;
using static Bullseye.Targets;
using static DotnetExeCommandLineBuilder.DotnetExeCommands;
Expand Down Expand Up @@ -73,17 +73,3 @@
Target("default", DependsOn("Test"));

await RunTargetsAndExitAsync(args);

public class ConsoleOutput : INScanOutput
{
public void WriteAnalysisReport(string analysisReport)
{
Console.WriteLine(analysisReport);
}

public void WriteVersion(string coreVersion)
{
Console.WriteLine(coreVersion);
}
}

2 changes: 1 addition & 1 deletion src/netstandard2.0/BuildScript/rules.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* hasNoCircularUsings
*Specification hasAttributesOn *Specification:Should*
AnyRoot hasProperty TargetFrameworks:net6.0;netstandard2.1
AnyRoot hasProperty TargetFrameworks:net8.0;netstandard2.1
*Specification hasProperty TargetFramework:net8.0
* hasProperty Nullable:enable
* hasProperty LangVersion:latest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TddXt.TypeReflection.ImplementationDetails.ConstructorRetrievals;
using TddXt.TypeReflection.ImplementationDetails.ConstructorRetrievals;

namespace TddXt.TypeReflection;

Expand All @@ -21,7 +21,7 @@ public ConstructorRetrievalFactory()
))))))));
}

private ConstructorRetrieval PrivateAndProtectedNonRecursiveConstructor(ConstructorRetrieval next)
private static ConstructorRetrieval PrivateAndProtectedNonRecursiveConstructor(ConstructorRetrieval next)
{
return new PrivateOrProtectedNonRecursiveConstructorRetrieval(next);
}
Expand Down Expand Up @@ -70,4 +70,4 @@ private static ConstructorRetrieval InternalParameterlessConstructors(Constructo
{
return new NonPublicParameterlessConstructorRetrieval(next);
}
}
}
8 changes: 4 additions & 4 deletions src/netstandard2.0/TypeReflection/GenericMethodProxyCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public object ResultOfGenericVersionOfMethod<T>(T instance, Type genericArgument

public object ResultOfGenericVersionOfStaticMethod<T>(Type genericArgumentType, string name)
{
return ResultOfGenericVersionOfStaticMethod<T>(genericArgumentType, name, new object[] { });
return ResultOfGenericVersionOfStaticMethod<T>(genericArgumentType, name, []);
}

public object ResultOfGenericVersionOfStaticMethod<T>(Type genericArgumentType, string name, params object[] parameters)
Expand All @@ -30,7 +30,7 @@ public object ResultOfGenericVersionOfStaticMethod<T>(Type genericArgumentType,
public object ResultOfGenericVersionOfStaticMethod<T>(
Type type1, Type type2, string name)
{
return ResultOfGenericVersionOfStaticMethod<T>(type1, type2, name, new object[] { });
return ResultOfGenericVersionOfStaticMethod<T>(type1, type2, name, []);
}

public object ResultOfGenericVersionOfStaticMethod<T>(
Expand All @@ -41,15 +41,15 @@ public object ResultOfGenericVersionOfStaticMethod<T>(
return genericMethod.Invoke(null, parameters).OrThrow();
}

private MethodInfo FindEmptyGenericsInstanceMethod<T>(
private static MethodInfo FindEmptyGenericsInstanceMethod<T>(
string name, object[] parameters)
{
return FindEmptyGenericsMethod<T>(name, parameters,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
}


private MethodInfo FindEmptyGenericsStaticMethod<T>(
private static MethodInfo FindEmptyGenericsStaticMethod<T>(
string name, object[] parameters)
{
return FindEmptyGenericsMethod<T>(name, parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public IEnumerable<IConstructorWrapper> RetrieveFrom(IConstructorQueries constru
var constructor = constructors.GetNonPublicParameterlessConstructorInfo();
if (constructor.HasValue)
{
return new List<IConstructorWrapper> { constructor.Value() };
return [constructor.Value()];
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public IEnumerable<IConstructorWrapper> RetrieveFrom(IConstructorQueries constru
var constructor = constructors.GetPublicParameterlessConstructor();
if (constructor.HasValue)
{
return new List<IConstructorWrapper> { constructor.Value() };
return [constructor.Value()];
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public bool HasNonPointerArgumentsOnly()

public bool HasLessParametersThan(int numberOfParams)
{
if (_parameters.Count() < numberOfParams)
if (_parameters.Length < numberOfParams)
{
return true;
}
Expand All @@ -58,7 +58,7 @@ public bool HasLessParametersThan(int numberOfParams)

public int GetParametersCount()
{
return _parameters.Count();
return _parameters.Length;
}

public bool HasAbstractOrInterfaceArguments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public bool HasAbstractOrInterfaceArguments()
public List<object> GenerateAnyParameterValues(Func<Type, GenerationRequest, object> instanceGenerator,
GenerationRequest request)
{
return new List<object>();
return [];
}

public bool IsParameterless()
Expand Down Expand Up @@ -66,7 +66,7 @@ public object Invoke(IEnumerable<object> parameters)
return creation.Invoke();
}

public IEnumerable<ParameterInfo> Parameters { get; } = new List<ParameterInfo>();
public IEnumerable<ParameterInfo> Parameters { get; } = [];

public void LogInScopeOf(GenerationRequest request)
{
Expand All @@ -75,11 +75,11 @@ public void LogInScopeOf(GenerationRequest request)

public static IConstructorWrapper ForOrdinaryType(ConstructorInfo constructorInfo)
{
return new DefaultParameterlessConstructor(() => constructorInfo.Invoke(new object[]{}));
return new DefaultParameterlessConstructor(() => constructorInfo.Invoke([]));
}

public static IEnumerable<IConstructorWrapper> ForValue(Type type)
{
return new [] { new DefaultParameterlessConstructor(() => Activator.CreateInstance(type).OrThrow())};
return [new DefaultParameterlessConstructor(() => Activator.CreateInstance(type).OrThrow())];
}
}
2 changes: 1 addition & 1 deletion src/netstandard2.0/TypeReflection/TypeReflection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<AssemblyName>TddXt.Any.TypeReflection</AssemblyName>
<RootNamespace>TddXt.TypeReflection</RootNamespace>
<Authors>Grzegorz Gałęzowski</Authors>
Expand Down
12 changes: 5 additions & 7 deletions src/netstandard2.0/TypeResolution/AllGeneratorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public static BasicGenerator Create()
var allGenerator = new AllGenerator(new LimitedGenerationChain(
new CustomizationSupportingChain(
new AutoFixtureChain(
new GeneratorsBasedChain(new[]
{
new GeneratorsBasedChain([
resolutionsFactory.ResolveAsHalf(),
resolutionsFactory.ResolveAsDateOnly(),
resolutionsFactory.ResolveAsNullable(),
Expand Down Expand Up @@ -67,18 +66,17 @@ public static BasicGenerator Create()
ResolutionsFactory.ResolveAsVoidTask(),
ResolutionsFactory.ResolveAsTypedTask(),
resolutionsFactory.ResolveAsConcreteClass()
})))),
])))),
new GeneratorsBasedChain(
new[]
{
dummyResolutionsFactory.ResolveDummyPrimitiveTypeInstance(),
[
dummyResolutionsFactory.ResolveDummyPrimitiveTypeInstance(),
dummyResolutionsFactory.ResolveDummyString(),
dummyResolutionsFactory.ResolveDummyOpenGenericImplementationOfIEnumerable(),
dummyResolutionsFactory.ResolveDummyOpenGenericIEnumerable(),
dummyResolutionsFactory.ResolveDummyAbstractType(),
resolutionsFactory.ResolveAsInterfaceImplementation(),
dummyResolutionsFactory.FallbackDummyObjectResolution()
}));
]));
return allGenerator;
}
}
Loading

0 comments on commit 26a0daa

Please sign in to comment.