© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
3 replies
RumTery

Hide private partial class/struct members

I am generating code based on a given class, this partial class contains a generated public interface and generated private members. Is it possible to hide the visibility of private members for the original non-generated class?

Some code example
[System]
internal partial class IterativeSystem
{
    [SystemCall]
    public void Do(int a, ref int b)
    {
        
    }
}
[System]
internal partial class IterativeSystem
{
    [SystemCall]
    public void Do(int a, ref int b)
    {
        
    }
}

internal partial class IterativeSystem
{
    private static Type[] _mutTypes = [typeof(int)];
    private static Type[] _readTypes = [typeof(int)];
    public ReadOnlySpan<Type> MutTypes => _mutTypes;
    public ReadOnlySpan<Type> ReadTypes => _readTypes;

    public void Update()
    {
        // __DoCall(IRuntimeContext.Current.World);
    }

    private readonly QueryDescription __DoQuery;
    private void __DoCall(World world)
    {
        var query = world.Query(in __DoQuery);
        foreach (ref var chunk in query)
        {
            var componentsFirst = chunk.GetFirst<int, int>();
            foreach (var entityIndex in chunk)
            {
                ref var t0Component = ref Unsafe.Add(ref componentsFirst.t0, entityIndex);
                ref var t1Component = ref Unsafe.Add(ref componentsFirst.t1, entityIndex);
                Do(t0Component, ref t1Component);
            }
        }
    }
}
internal partial class IterativeSystem
{
    private static Type[] _mutTypes = [typeof(int)];
    private static Type[] _readTypes = [typeof(int)];
    public ReadOnlySpan<Type> MutTypes => _mutTypes;
    public ReadOnlySpan<Type> ReadTypes => _readTypes;

    public void Update()
    {
        // __DoCall(IRuntimeContext.Current.World);
    }

    private readonly QueryDescription __DoQuery;
    private void __DoCall(World world)
    {
        var query = world.Query(in __DoQuery);
        foreach (ref var chunk in query)
        {
            var componentsFirst = chunk.GetFirst<int, int>();
            foreach (var entityIndex in chunk)
            {
                ref var t0Component = ref Unsafe.Add(ref componentsFirst.t0, entityIndex);
                ref var t1Component = ref Unsafe.Add(ref componentsFirst.t1, entityIndex);
                Do(t0Component, ref t1Component);
            }
        }
    }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Partial class problem
C#CC# / help
3mo ago
❔ Struct vs Class
C#CC# / help
3y ago
readonly struct and readonly struct instance members (optimization?)
C#CC# / help
4y ago
CS0122, just with a partial class...
C#CC# / help
3y ago