Skip to content

[Bug]: Use string .ToProperty overload to avoid performance costly Expression overload. #72

@AmrAlSayed0

Description

@AmrAlSayed0

Describe the bug 🐞

The .ToProperty overload that takes Expression<Func<TObj, TRet>> is used instead of the one that takes string.

if (propertyInfo.IsProperty)
{
propertyInitilisers.Add(ParseStatement($"{fieldIdentifierName}Helper = {propertyInfo.MethodName}!.ToProperty(this, x => x.{propertyInfo.PropertyName});"));
}
else
{
propertyInitilisers.Add(ParseStatement($"{fieldIdentifierName}Helper = {propertyInfo.MethodName}()!.ToProperty(this, x => x.{propertyInfo.PropertyName});"));
}

Part of the usefulness of source generators is that they can move some of the work done at runtime through reflection and other ways to compile time. This goes against that. It negatively affects performance when it really didn't need to.

Also, it would be very useful to add some of the other parameters of .ToProperty like bool deferSubscription and TRet initialValue.

Step to reproduce

N/A

Reproduction repository

No response

Expected behavior

N/A

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

No response

Additional information ℹ️

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions