Skip to content

Support for Structs and Classes that use primary constructors in C# #81

@aalramadan

Description

@aalramadan

Currently, Stereocode does not correctly recognize a struct or a class that uses the primary constructor syntax. The constructor logic is defined directly in the type declaration line rather than a traditional method body.

Example:

public struct RECT(int left, int top)
{
    public int Left = left;
    public int Top = top;
}

Is the same as:

public struct RECT
{
    public int Left;
    public int Top;

    public RECT(int left, int top,)
    {
        Left = left;
        Top = top;
    }
}

srcML

<function><type><specifier>public</specifier> <name><name>struct</name> <name>RECT</name></name></type>(<name>int</name> <name>left</name>, <name>int</name> <name>top</name></function>)
<block>{<block_content>
    <decl_stmt><decl><type><specifier>public</specifier> <name>int</name></type> <name>Left</name> <init>= <expr><name>left</name></expr></init></decl>;</decl_stmt>
    <decl_stmt><decl><type><specifier>public</specifier> <name>int</name></type> <name>Top</name> <init>= <expr><name>top</name></expr></init></decl>;</decl_stmt>
</block_content>}</block>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions