Metalama icon indicating copy to clipboard operation
Metalama copied to clipboard

Feature: Specify 'this' keyword on introduced parameters

Open WhitWaldo opened this issue 1 year ago • 1 comments

I would like to introduce a static extension method to a type and am able to create the method and mark it as static without issue. But when introducing the parameters to the introduced method, there isn't an option to indicate that the 'this' keyword should be inserted, leaving one unable to actually create an extension method.

        var serviceCollectionType = (INamedType)TypeFactory.GetType(typeof(IServiceCollection));
        
        builderType.IntroduceMethod(nameof(BuildMethodTemplate),
            IntroductionScope.Static,
            buildMethod: b =>
            {
                b.Name = "RegisterAllEntities";
                b.Accessibility = Accessibility.Public;
                //b.AddParameter("serviceCollection", serviceCollectionType); //Need some way to specify 'this'
            });

I would like to request such a capability. Thank you for the consideration!

WhitWaldo avatar Jul 22 '24 14:07 WhitWaldo

Thank you for spotting this gap.

gfraiteur avatar Jul 25 '24 18:07 gfraiteur

This feature has been added in Metalama 2025.0.5-preview.

prochan2 avatar Nov 08 '24 15:11 prochan2