templating icon indicating copy to clipboard operation
templating copied to clipboard

Should RunSpec._overrides be nullable

Open SimonCropp opened this issue 1 year ago • 0 comments

https://github.com/dotnet/templating/blob/main/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunSpec.cs

internal class RunSpec : IRunSpec
{
    private readonly IReadOnlyList<IOperationProvider> _overrides;

    internal RunSpec(IReadOnlyList<IOperationProvider> operationOverrides, string? variableFormatString)
    {
        _overrides = operationOverrides;
        VariableFormatString = variableFormatString ?? "{0}";
    }

    public string VariableFormatString { get; }

    public bool TryGetTargetRelPath(string sourceRelPath, out string? targetRelPath)
    {
        targetRelPath = null;
        return false;
    }

    public IReadOnlyList<IOperationProvider> GetOperations(IReadOnlyList<IOperationProvider> sourceOperations)
    {
        return _overrides ?? sourceOperations;
    }
}

since _overrides the ?? sourceOperations part of GetOperations should never be executed.

What am i missing here?

SimonCropp avatar Jun 11 '24 05:06 SimonCropp