Skip to content

Cannot control generated [Query] accessibility #90

Open
@LilithSilver

Description

@LilithSilver

Problem

Currently, all methods generated with [Query] are, by default, public, regardless of the accessibility of the method.

This causes several problems:

  • Private, class-local types cannot be used in a query method header, even if the method is only called within the system. For example, if a private struct SomeLocalInfo {} is defined within the BaseSystem, that can never be used as a [Data] parameter within a query without exposing it to the public.
  • Systems can never be public in a module, unless you want all your queries to be exposed to the public API. Instead, a module must manually wrap all systems and make all systems internal (extremely bad, if you're making a game engine with drop-in systems!)

Solution

Instead, provide a parameter to the [Query] attribute:

public enum QueryAccessibility
{
    CopyMethod, // copy the source method's accessibility
    // fill in attributes from  Microsoft.CodeAnalysis.Accessibility
}

public class QueryAttribute : Attribute
{
    QueryAccessibility Accessibility = QueryAccessibility.CopyMethod;
}

By default, the query could either be public, or copy the source method's accessibility, depending on whether it's super important to maintain API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions