Skip to content

C#: enum members are not nodes, so the enum type is a leaf and "which value does this branch on" has no answer #3063

Description

@durmazoguzhan

Environment

  • graphify 0.9.49 (PyPI graphifyy), Linux, Python 3.12
  • graphify extract <service> --code-only --no-cluster

Summary

C# enum members are not extracted as nodes. enum_declaration is in _CSHARP_CONFIG.class_types, so the enum type gets a node, but nothing under it does, and the type sits in the graph as a leaf with no outgoing edges.

This is the same gap #1700 reported for Kotlin/Java, fixed for Java in #1719 and Kotlin in #1738. Swift emits case_of for enum_entry, and PowerShell enum members landed in 0.9.49 via #3002. C# was not brought along.

Reproducer

// ProcessingType.cs
namespace Catalog.Events;

public enum ProcessingType
{
    Process = 0,
    ProcessAndCompleteIndex = 1
}

Current behavior (0.9.49)

processingtype                                (file)
csharp_namespace:9b597bd1e93a863b             (namespace)
processingtype_catalog_events_processingtype  (enum type, no children)

Process and ProcessAndCompleteIndex are nowhere in the node table, and the enum node has zero outgoing edges.

Measured on a 7-service .NET corpus (42,645 nodes / 98,269 edges): zero case_of edges, and the enum types I checked (ProcessingType, EntityType, ProductType, VariantType) are all leaves.

Expected

The Java shape, applied to C#:

processingtype_catalog_events_processingtype --case_of--> ..._processingtype_process
processingtype_catalog_events_processingtype --case_of--> ..._processingtype_processandcompleteindex

Why it matters here

In this corpus enum values are dispatch keys, not decoration. A consumer branches on EntityType to decide which id-resolution path to take, and a bulk index run is finished by one specific ProcessingType value. Asking the graph "which value completes the index run" currently cannot even surface that the value exists, because the name is not in the node table.

Same as #1700 concluded: even without a usage edge, having the member as a searchable node lets you find the definition and fall back to text search for the uses.

Note on grammar

The walk already reaches the members. enum_declaration's body field resolves to enum_member_declaration_list, whose children are enum_member_declaration nodes carrying a name field, and the C# class handler descends into the body with the enum as parent_class_nid. There is just no handler for that node type.

One C#-specific wrinkle: the language is case-sensitive, so enum E { Value, value } is legal while normalize_id casefolds, which means both members compete for one id.

I have a patch and will open it against this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions