Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add internal source generator for experimental features #18302

@SeeminglyScience

Description

@SeeminglyScience

Summary of the new feature / enhancement

There's a lot of boiler plate in experimental features, it'd be nice to have a source generator which takes this code:

NOTE: Of course this would only benefit folks working on this repo specifically, but it would greatly simplify adding experimental features in the engine and leave less room for typos/missed files.

public partial class ExperimentalFeature
{
                          // Probably default to this
    [Experiment(Targets = ExperimentTarget.Windows | ExperimentTarget.Linux)]
    private static readonly ExperimentalFeature PSDoSomething = new ExperimentalFeature(
        nameof(PSDoSomething),
        "The description for the feature");

    [Experiment(Targets = ExperimentTarget.Linux)]
    private static readonly ExperimentalFeature PSDoSomething2 = new ExperimentalFeature(
        nameof(PSDoSomething2),
        "The description for the feature");
}

and have it generate:

public partial class ExperimentalFeature
{
    internal static bool IsPSDoSomethingEnabled => EnabledExperimentalFeatureNames.Contains(nameof(PSDoSomething));

    
    internal static bool IsPSDoSomething2Enabled => EnabledExperimentalFeatureNames.Contains(nameof(PSDoSomething2));

	// Replacing the manual bit currently in the static ctor
    private static ExperimentalFeature[] CreateFeatureList()
    	=> new[]
        {
            PSDoSomething,
            PSDoSomething2,
        };
}

and

// experimental-feature-linux.json
[
    "PSDoSomething",
    "PSDoSomething2"
]
// experimental-feature-windows.json
[
    "PSDoSomething",
]

Proposed technical implementation details (optional)

No response

Metadata

Metadata

Labels

Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions