autofac / Autofac

An addictive .NET IoC container
https://autofac.org
MIT License
4.44k stars 836 forks source link

Where did all my code go? (THANK YOU re ```required``` properties) #1371

Closed TonyValenti closed 1 year ago

TonyValenti commented 1 year ago

I just wanted to voice a big thank you to @tillig and @alistairjevans for their awesome work on this.

Here is a before and after example:

Before

        protected Matter_Results<long> MatterResults { get; }
        protected User_Results<long> UserResults { get; }
        protected Invoice_Results<long> InvoiceResults { get; }
        protected FeeActivityTemplate_Rows Templates { get; }

        public FeeActivityAgent(
            FeeActivityAgentOptions Options,
            AgentArgs Args

            , Matter_Results<long> MatterResults
            , User_Results<long> UserResults
            , Invoice_Results<long> InvoiceResults
            , FeeActivityTemplate_Rows Templates

            ) : base(Options, Args
                , MatterResults
                , UserResults
                , InvoiceResults
                ) {

            this.MatterResults = MatterResults;
            this.UserResults = UserResults;
            this.InvoiceResults = InvoiceResults;
            this.Templates = Templates;

        }

After

        public required Matter_Results<long> MatterResults { protected get; init; }
        public required User_Results<long> UserResults { protected get; init; }
        public required Invoice_Results<long> InvoiceResults { protected get; init; }
        public required FeeActivityTemplate_Rows Templates { protected get; init; }

Obviously there is now a ton of rote boilerplate that is now gone. Thank you!

alistairjevans commented 1 year ago

Thanks for the appeciation @TonyValenti, nice to see some code getting deleted!