Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up .net 8
uses: actions/setup-dotnet@v3
- name: Set up .net 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: '9.0.x'
- name: Set up JDK 21
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 21
- uses: actions/checkout@v2
java-version: '21'
distribution: 'oracle'
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var file = new CsFile(
},
"App",
new List<Constructor>(),
new List<Field>(),
new List<Property>(),
new List<Method>
{
Expand Down
21 changes: 16 additions & 5 deletions RefleCS/RefleCS.TestKit/Nodes/ClassBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ClassBuilder WithModifiers(IEnumerable<ClassModifier> modifiers)

public ClassBuilder WithEmptyModifiers()
{
return WithModifiers(Enumerable.Empty<ClassModifier>());
return WithModifiers([]);
}

public ClassBuilder WithConstructors(IEnumerable<Constructor> constructors)
Expand All @@ -38,7 +38,18 @@ public ClassBuilder WithConstructors(IEnumerable<Constructor> constructors)

public ClassBuilder WithEmptyConstructors()
{
return WithConstructors(Enumerable.Empty<Constructor>());
return WithConstructors([]);
}

public ClassBuilder WithFields(IEnumerable<Field> fields)
{
FillConstructorWith(nameof(fields), fields);
return this;
}

public ClassBuilder WithEmptyFields()
{
return WithFields([]);
}

public ClassBuilder WithProperties(IEnumerable<Property> properties)
Expand All @@ -49,7 +60,7 @@ public ClassBuilder WithProperties(IEnumerable<Property> properties)

public ClassBuilder WithEmptyProperties()
{
return WithProperties(Enumerable.Empty<Property>());
return WithProperties([]);
}

public ClassBuilder WithMethods(IEnumerable<Method> methods)
Expand All @@ -60,7 +71,7 @@ public ClassBuilder WithMethods(IEnumerable<Method> methods)

public ClassBuilder WithEmptyMethods()
{
return WithMethods(Enumerable.Empty<Method>());
return WithMethods([]);
}

public ClassBuilder WithBaseTypes(IEnumerable<BaseType> baseTypes)
Expand All @@ -71,6 +82,6 @@ public ClassBuilder WithBaseTypes(IEnumerable<BaseType> baseTypes)

public ClassBuilder WithEmptyBaseTypes()
{
return WithBaseTypes(Enumerable.Empty<BaseType>());
return WithBaseTypes([]);
}
}
40 changes: 40 additions & 0 deletions RefleCS/RefleCS.TestKit/Nodes/FieldBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using RefleCS.Enums;
using RefleCS.Nodes;

namespace RefleCS.TestKit.Nodes;
public class FieldBuilder : TestBuilderBase<Field>
{
public FieldBuilder WithModifiers(IEnumerable<FieldModifier> modifiers)
{
FillConstructorWith(nameof(modifiers), modifiers);
return this;
}

public FieldBuilder WithEmptyModifiers()
{
return WithModifiers(Enumerable.Empty<FieldModifier>());
}

public FieldBuilder WithTypeName(string typeName)
{
FillConstructorWith(nameof(typeName), typeName);
return this;
}

public FieldBuilder WithName(string name)
{
FillConstructorWith(nameof(name), name);
return this;
}

public FieldBuilder WithInitializer(FieldInitializer? initializer)
{
FillConstructorWith(nameof(initializer), initializer);
return this;
}

public FieldBuilder WithoutInitializer()
{
return WithInitializer(null);
}
}
4 changes: 2 additions & 2 deletions RefleCS/RefleCS.TestKit/RefleCS.TestKit.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<PackageReference Include="Castle.Core" Version="5.1.1" />
<PackageReference Include="Castle.Core" Version="5.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion RefleCS/RefleCS.TestTools/RefleCS.TestTools.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
51 changes: 43 additions & 8 deletions RefleCS/RefleCS.Tests/Converters/CsFileConverterTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ public IEnumerator<object[]> GetEnumerator()
{
yield return WithRecord();
yield return WithClass();
yield return WithClass_EmptyFieldInitializer();
}

private object[] WithRecord()
{
return new object[]
{
return
[
new CsFile(
new List<Using> { new("System") },
new Namespace(
"MyApp",
Enumerable.Empty<Class>(),
[],
new List<Record>
{
new(
Expand Down Expand Up @@ -49,13 +50,13 @@ private object[] WithRecord()
new List<Method>(),
new List<BaseType>())
}))
};
];
}

private object[] WithClass()
{
return new object[]
{
return
[
new CsFile(
new List<Using>
{
Expand All @@ -80,6 +81,10 @@ private object[] WithClass()
new List<Argument> { new("ids") }),
new List<Statement> { new("Console.Log(\"Hello, World!\");") })
},
new List<Field>
{
new([FieldModifier.Public], "string", "_myString", new("\"Test\""))
},
new List<Property>
{
new(
Expand Down Expand Up @@ -110,8 +115,38 @@ private object[] WithClass()
},
new List<BaseType> { new("MyBaseClass") })
},
Enumerable.Empty<Record>()))
};
[]))
];
}

private object[] WithClass_EmptyFieldInitializer()
{
return
[
new CsFile(
new List<Using>
{
new("System"),
new("System.Linq")
},
new Namespace(
"MyApp",
new List<Class>
{
new(
new List<ClassModifier> { ClassModifier.Private },
"MyClass",
new List<Constructor>(),
new List<Field>
{
new([FieldModifier.Public], "string", "_myString", null)
},
new List<Property>(),
new List<Method>(),
new List<BaseType> { new("MyBaseClass") })
},
[]))
];
}

IEnumerator IEnumerable.GetEnumerator()
Expand Down
24 changes: 12 additions & 12 deletions RefleCS/RefleCS.Tests/Converters/RecordConverterTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public IEnumerator<object[]> GetEnumerator()

private static object[] OnlyParameters()
{
return new object[]
{
return
[
new Record(
new List<ClassModifier> { ClassModifier.Public },
"App",
Expand All @@ -26,13 +26,13 @@ private static object[] OnlyParameters()
new List<Property>(),
new List<Method>(),
new List<BaseType>())
};
];
}

private static object[] WithConstructor()
{
return new object[]
{
return
[
new Record(
new List<ClassModifier> { ClassModifier.Public },
"App",
Expand All @@ -58,13 +58,13 @@ private static object[] WithConstructor()
},
new List<Method>(),
new List<BaseType>())
};
];
}

private static object[] WithMethods()
{
return new object[]
{
return
[
new Record(
new List<ClassModifier> { ClassModifier.Public },
"App",
Expand Down Expand Up @@ -98,13 +98,13 @@ private static object[] WithMethods()
new List<Statement> { new("nextVal = Ids.First()") })
},
new List<BaseType>())
};
];
}

private static object[] WithBaseType()
{
return new object[]
{
return
[
new Record(
new List<ClassModifier> { ClassModifier.Public },
"App",
Expand All @@ -116,7 +116,7 @@ private static object[] WithBaseType()
{
new("MyBaseApp")
})
};
];
}

IEnumerator IEnumerable.GetEnumerator()
Expand Down
Loading
Loading