Skip to main content

rscg_demeter by Andrei Ignat

NuGet / site data​

Nuget GitHub last commit GitHub Repo stars

Details​

Info​

info

Name: rscg_demeter

Interface to null object - common

Author: Andrei Ignat

NuGet: https://www.nuget.org/packages/rscg_demeter/

You can find more details at https://github.com/ignatandrei/rscg_demeter/

Source: https://github.com/ignatandrei/rscg_demeter/

Original Readme​

note

RSCG_Demeter

Demeter Law : http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx/

Usage

Add the package RSCG_Demeter to the csproj

	<ItemGroup>
<PackageReference Include="RSCG_Demeter" Version="2026.328.706" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

Then build the project - the analyzer will run and show the errors in the error list.

Export​

Add this to the csproj

	<ItemGroup>
<CompilerVisibleProperty Include="RSCG_Demeter_GenerateFile" />
</ItemGroup>
<PropertyGroup>
<RSCG_Demeter_GenerateFile>../YourProjectName.csproj.txt</RSCG_Demeter_GenerateFile>
</PropertyGroup>

And the file YourProjectName.csproj.txt will be generated with the errors.

About​

note

Generating diagnostics about Law of Demeter violations

How to use​

Example (source csproj, source files)​

This is the CSharp Project that references rscg_demeter

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>CS0436,NU1903</WarningsNotAsErrors>

</PropertyGroup>

<ItemGroup>
<CompilerVisibleProperty Include="RSCG_Demeter_GenerateFile" />
</ItemGroup>

<PropertyGroup>
<RSCG_Demeter_GenerateFile>obj/gx/RSCG_Console.csproj.txt</RSCG_Demeter_GenerateFile>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.3" />
<PackageReference Include="RSCG_Demeter" Version="2026.328.706" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>



<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>

Generated Files​

Those are taken from $(BaseIntermediateOutputPath)\GX

{
"dateGenerator": "20250329050839",
"nameGenerator": "Gerhart Hauptmann is feeling agreeable in Porto-Novo",
"maxDemeterDots": 3,
"locationsFound": 5,
"DemeterLocations": [
{
"id": 1,
"startLine": 5,
"nrDots": 2,
"endLine": 5,
"filePath": "D:\\eu\\GitHub\\RSCG_Examples\\v2\\rscg_examples\\rscg_demeter\\src\\RSCG_Console\\Program.cs",
"text": "dep.Employees.Add(new Employee())"
},
{
"id": 2,
"startLine": 9,
"nrDots": 2,
"endLine": 9,
"filePath": "D:\\eu\\GitHub\\RSCG_Examples\\v2\\rscg_examples\\rscg_demeter\\src\\RSCG_Console\\Program.cs",
"text": " dep.EmployeeNames.Add(emp.Name)"
},
{
"id": 3,
"startLine": 12,
"nrDots": 2,
"endLine": 12,
"filePath": "D:\\eu\\GitHub\\RSCG_Examples\\v2\\rscg_examples\\rscg_demeter\\src\\RSCG_Console\\Program.cs",
"text": "it.Name.StartsWith(\u0022a\u0022)"
},
{
"id": 4,
"startLine": 14,
"nrDots": 2,
"endLine": 14,
"filePath": "D:\\eu\\GitHub\\RSCG_Examples\\v2\\rscg_examples\\rscg_demeter\\src\\RSCG_Console\\Program.cs",
"text": "empAll.Select(it =\u003E it.ID).Distinct().OrderBy(it =\u003E it)"
},
{
"id": 5,
"startLine": 17,
"nrDots": 3,
"endLine": 20,
"filePath": "D:\\eu\\GitHub\\RSCG_Examples\\v2\\rscg_examples\\rscg_demeter\\src\\RSCG_Console\\Program.cs",
"text": "AppDomain.CurrentDomain.GetAssemblies()\r\n .Where(it =\u003E data.Any(a =\u003E !(it.FullName?.StartsWith(a) ?? false)))\r\n .Distinct()\r\n .ToArray()"
}
]
}

Useful​

Download Example (.NET C#)​

Share rscg_demeter​

https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg_demeter

aaa

Category "FunctionalProgramming" has the following generators:​

1 cachesourcegenerator Nuget GitHub Repo stars 2024-02-14

2 dunet Nuget GitHub Repo stars 2023-04-16

3 Dusharp Nuget GitHub Repo stars 2024-09-19

4 Funcky.DiscriminatedUnion Nuget GitHub Repo stars 2024-01-18

5 FunicularSwitch NugetNuget GitHub Repo stars 2024-02-12

6 N.SourceGenerators.UnionTypes Nuget GitHub Repo stars 2023-10-29

7 OneOf NugetNuget GitHub Repo stars 2023-08-21

8 PartiallyApplied Nuget GitHub Repo stars 2023-04-16

9 polytype Nuget GitHub Repo stars 2024-11-04

10 rscg_demeter Nuget GitHub Repo stars 2025-03-26

11 rscg_queryables NugetNuget GitHub Repo stars 2024-11-02

12 RSCG_Utils_Memo Nuget GitHub Repo stars 2023-08-27

13 ScottEncodingGenerator Nuget GitHub Repo stars 2026-06-30

14 Sera.Union Nuget GitHub Repo stars 2024-08-26

15 Sundew.DiscriminatedUnions Nuget GitHub Repo stars 2026-02-14

16 TypeUtilities Nuget GitHub Repo stars 2024-03-05

17 UnionGen Nuget GitHub Repo stars 2024-04-05

18 UnionsGenerator Nuget GitHub Repo stars 2024-02-18

See category​

FunctionalProgramming