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

2 dunet

3 Dusharp

4 Funcky.DiscriminatedUnion

5 FunicularSwitch

6 N.SourceGenerators.UnionTypes

7 OneOf

8 PartiallyApplied

9 polytype

10 rscg_demeter

11 rscg_queryables

12 RSCG_Utils_Memo

13 Sera.Union

14 TypeUtilities

15 UnionGen

16 UnionsGenerator

See category

FunctionalProgramming