Skip to content

Possible interface proxy unnecessary initialization #2271

Open
@bahusoid

Description

@bahusoid

If proxy interface IProxy implements multiple interfaces with identifier property:

interface IReadOnlyId
{
	int Id { get; }
}

interface IId
{
	int Id { get; set; }
}

//IProxy contains both IReadOnlyId.Id and IId.Id getters. It's ambiguous but valid code
interface IProxy : IId,  IReadOnlyId
{
}

public class Entity : IProxy
{
	public virtual int Id { get; set; }
}

Currently generated proxy initializes proxy IProxy on IReadOnlyId.Id access:

IReadOnlyId entity = session.Load<IProxy>(id);
Console.WriteLine(entity.Id); // <- entity will be initialized on entity.Id access

It should not trigger proxy initialization.

Possible solution: implement class for interface proxy members implicitly.

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