Skip to content

Support abstract [LuaObject] classes#302

Merged
nuskey8 merged 1 commit into
nuskey8:mainfrom
ashtonmeuser:abstract-support
May 6, 2026
Merged

Support abstract [LuaObject] classes#302
nuskey8 merged 1 commit into
nuskey8:mainfrom
ashtonmeuser:abstract-support

Conversation

@ashtonmeuser
Copy link
Copy Markdown
Contributor

The guard against abstract classes is, in my opinion, a little conservative. Users who desire an abstract parent class may simply drop abstract to appease Lua-CSharp, which is a worse compromise.

If I've overlooked a massive trap, please let me know.

@ashtonmeuser
Copy link
Copy Markdown
Contributor Author

Perhaps this isn't necessary. The abstract parent class can simply omit [LuaObject] and add [LuaMember] all the same. A concrete child class with [LuaObject] will pick these up. For example:

public abstract partial class ParentClass
{
    [LuaMember("value")]
    public string Value { get; set; } = "";
}

[LuaObject]
public partial class ChildClass : ParentClass
{
    [LuaMember("number")]
    public int Number { get; set; }
}

ChildClass still has access to value.

@nuskey8
Copy link
Copy Markdown
Owner

nuskey8 commented May 5, 2026

This looks good, but are there any concerns? @akeit0

@akeit0
Copy link
Copy Markdown
Collaborator

akeit0 commented May 5, 2026

LGTM!

@nuskey8
Copy link
Copy Markdown
Owner

nuskey8 commented May 5, 2026

It seems fine for abstract classes, but simply removing this check might cause code to be generated for interfaces as well. Wouldn't a proper check be necessary for this?

Sorry, that was a mistake. This is properly filtered at the SyntaxProvider stage.

@nuskey8 nuskey8 merged commit f2472b1 into nuskey8:main May 6, 2026
@nuskey8
Copy link
Copy Markdown
Owner

nuskey8 commented May 6, 2026

Merged the PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants