Skip to content

Commit 3f56d00

Browse files
committed
example
1 parent 3d36ff8 commit 3f56d00

10 files changed

Lines changed: 181 additions & 0 deletions

File tree

v2/RSCGExamplesData/GeneratorDataRec.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,5 +1147,11 @@
11471147
"Category": 19,
11481148
"dtStart": "2025-03-25T00:00:00",
11491149
"show": true
1150+
},
1151+
{
1152+
"ID":"rscg_demeter",
1153+
"Category": 10,
1154+
"dtStart": "2025-03-26T00:00:00",
1155+
"show": true
11501156
}
11511157
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"generator":{
3+
"name":"rscg_demeter",
4+
"nuget":[
5+
"https://www.nuget.org/packages/rscg_demeter/"
6+
],
7+
"link":"https://github.com/ignatandrei/rscg_demeter/",
8+
"author":"Andrei Ignat",
9+
"source":"https://github.com/ignatandrei/rscg_demeter/"
10+
},
11+
"data":{
12+
"goodFor":["Generating diagnostics about Law of Demeter violations"],
13+
"csprojDemo":"RSCG_Console.csproj",
14+
"csFiles":["Program.cs"],
15+
"excludeDirectoryGenerated":["NameGenerator"],
16+
"includeAdditionalFiles":["RSCG_Console.csproj.txt"]
17+
},
18+
"links":{
19+
"blog":"",
20+
"video":""
21+
}
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace RSCG_Console;
2+
internal class Department
3+
{
4+
public string Name { get; set; } = string.Empty;
5+
public List<Employee> Employees{ get; set; } = [];
6+
7+
public List<string> EmployeeNames { get; set; }= [];
8+
9+
public int GetEmployees()
10+
{
11+
return Employees.Count;
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace RSCG_Console;
2+
internal class EmpBuilder
3+
{
4+
Employee emp=new Employee();
5+
public Employee BuildEmployee()
6+
{
7+
var data = new Employee();
8+
data.Name = emp.Name;
9+
data.ID = emp.ID;
10+
emp=new Employee();
11+
return data ;
12+
}
13+
public EmpBuilder SetName(string name)
14+
{
15+
emp.Name = name;
16+
return this;
17+
}
18+
public EmpBuilder SetId(int id)
19+
{
20+
emp.ID = id;
21+
return this;
22+
}
23+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace RSCG_Console;
2+
internal class Employee
3+
{
4+
public string Name { get; set; } = string.Empty;
5+
public int ID { get; set; }
6+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// See https://aka.ms/new-console-template for more information
2+
using RSCG_Console;
3+
4+
Console.WriteLine("Hello, World!");
5+
var dep = new Department();
6+
dep.Employees.Add(new Employee());
7+
8+
foreach (var emp in dep.Employees)
9+
{
10+
dep.EmployeeNames.Add(emp.Name);
11+
}
12+
var empAll = dep.Employees;
13+
var empWithA = empAll.Where(it => it.Name.StartsWith("a"));
14+
await Task.Run(dep.GetEmployees);
15+
var asda = new List<int>(empAll.Select(it => it.ID).Distinct().OrderBy(it => it));
16+
Console.WriteLine(asda.Count);
17+
List<string> data = [];
18+
var d = AppDomain.CurrentDomain.GetAssemblies()
19+
.Where(it => data.Any(a => !(it.FullName?.StartsWith(a) ?? false)))
20+
.Distinct()
21+
.ToArray();
22+
23+
var builder = new EmpBuilder().SetName("Ignat").SetId(1).SetName("Andrei");
24+
var emp1 =builder.BuildEmployee();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsPackable>false</IsPackable>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<WarningsNotAsErrors>CS0436,NU1903</WarningsNotAsErrors>
11+
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<CompilerVisibleProperty Include="RSCG_Demeter_GenerateFile" />
16+
</ItemGroup>
17+
18+
<PropertyGroup>
19+
<RSCG_Demeter_GenerateFile>obj/gx/RSCG_Console.csproj.txt</RSCG_Demeter_GenerateFile>
20+
</PropertyGroup>
21+
22+
23+
<ItemGroup>
24+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.3" />
25+
<PackageReference Include="RSCG_Demeter" Version="2026.328.706" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
26+
</ItemGroup>
27+
28+
29+
30+
<PropertyGroup>
31+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
32+
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
33+
</PropertyGroup>
34+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
while($true)
2+
{
3+
4+
cls
5+
Write-Host "delete obj and bin"
6+
gci obj -recurse | foreach{ri $_.FullName -recurse -force }
7+
gci bin -recurse | foreach{ri $_.FullName -recurse -force }
8+
dotnet clean
9+
dotnet restore
10+
dotnet build /p:EmitCompilerGeneratedFiles=true --disable-build-servers --force
11+
dotnet run
12+
Read-Host -Prompt "Press Enter to continue"
13+
14+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35828.75
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RSCG_Console", "RSCG_Console\RSCG_Console.csproj", "{9132FC5B-110D-4CAC-891B-CCCDC37E3D75}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{9132FC5B-110D-4CAC-891B-CCCDC37E3D75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9132FC5B-110D-4CAC-891B-CCCDC37E3D75}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9132FC5B-110D-4CAC-891B-CCCDC37E3D75}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9132FC5B-110D-4CAC-891B-CCCDC37E3D75}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EDDC8C3F-2461-4A39-AD9B-9F600FE26CF8}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
while($true)
2+
{
3+
4+
cls
5+
Write-Host "delete obj and bin"
6+
gci obj -recurse | foreach{ri $_.FullName -recurse -force }
7+
gci bin -recurse | foreach{ri $_.FullName -recurse -force }
8+
dotnet clean
9+
dotnet restore
10+
dotnet build /p:EmitCompilerGeneratedFiles=true --disable-build-servers --force
11+
# dotnet run
12+
Read-Host -Prompt "Press Enter to continue"
13+
14+
}

0 commit comments

Comments
 (0)