Skip to content

Replacing properties private T Service { get; } = Ioc.Default.GetRequiredService<T>() by readonly field #11008

@QuaintMako

Description

@QuaintMako

Description

Across the source code, we can find properties of this kind :

private T Service { get; } = Ioc.Default.GetRequiredService<T>()

As of late, in order to do some small optimizations, we started to replace properties retrieving IUserSettingsService by private readonly fields instead. There are other types of settings that are fetched by the same process. We should replace them as well by fields of this format:

private readonly T service = Ioc.Default.GetRequiredService<T>() (Note that the name variable starts by a lowercase letter)

Concerned code

  • Whole solution.

Gains

  • A slightly more optimized code.
  • A more coherent code.

Requirements

  • private T Service { get; } = Ioc.Default.GetRequiredService<T>() are made into private readonly T service = Ioc.Default.GetRequiredService<T>()
  • Public properties for sharing this format should be modified to look like this :
private readonly T service = Ioc.Default.GetRequiredService<T>();
public T Service 
{ 
    get => return service; 
}

Comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions