Skip to content

Call data portal operation methods explicitly #4359

@rockfordlhotka

Description

@rockfordlhotka

Today, data portal operation methods are private and are called dynamically by the data portal. They are identified by attributes such as Fetch or Update.

This is a problem because AOT will optimize these methods out of the codebase. It is also a problem because Visual Studio grays out the code, thinking it is never invoked.

Using a code generator, it might be possible to explicitly invoke these methods. Here are my initial thoughts on how such a thing might work.

  1. A generator can look at the code and identify all data portal operation methods
  2. The generator can create an interface that includes all the methods, and code to implement the interface explicitly - invoking the actual methods
  3. The server-side data portal can be changed to detect this interface, and if it exists, to use the interface for invoking methods instead of invoking the private methods (which may provide slight performance improvement)

For example:

    public partial class PersonEdit : BusinessBase<PersonEdit>
    {
        public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
        public string Name
        {
            get => GetProperty(NameProperty);
            set => SetProperty(NameProperty, value);
        }

        [Fetch]
        private void Fetch(string name)
        {
            LoadProperty(NameProperty, name);
        }
    }

    // generated code:

    public interface IPersonEditOperations
    {
        void Fetch(string name);
    }

    public partial class PersonEdit : IPersonEditOperations
    {
        void IPersonEditOperations.Fetch(string name) => Fetch(name);
    }

Metadata

Metadata

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions