Skip to content

Cake Frosting Parent DirectoryPath Fails To Combine with Slash #3352

@lprichar

Description

@lprichar

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake Frosting

Cake version

1.1.0

Operating system

Linux, Windows

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

A NullReferenceException in the code sample below. However, that's more the symptom than the cause. The problem appears to be that Cake Frosting is combining Directory("..") + Directory("temp") into "..temp" rather than "../temp" when you capture the context and then use expression bodied properties.

This may seem obscure, but I'm converting a large codebase of DSL Cake into Frosting and am looking for ways to accomplish it with minimal changes.

What is expected?

It should run to completion without an exception

Steps to Reproduce

Run this:

[TaskName("Fail")]
public class FailTask : FrostingTask<BuildContext>
{
    private BuildContext? _context;
    private DirectoryPath RootDir => _context.Directory("..");
    private DirectoryPath TestDir => RootDir + _context.Directory("temp");

    public override void Run(BuildContext context)
    {
        _context = context;
        context.GetFiles(TestDir + context.File("*.zip"));
    }
}

Output log

Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Cake.Core.IO.Globbing.GlobVisitor.VisitParent(ParentDirectoryNode node, GlobVisitorContext context)
   at Cake.Core.IO.Globbing.Nodes.ParentDirectoryNode.Accept(GlobVisitor visitor, GlobVisitorContext context)
   at Cake.Core.IO.Globbing.GlobVisitor.VisitRelativeRoot(RelativeRootNode node, GlobVisitorContext context)
   at Cake.Core.IO.Globbing.Nodes.RelativeRootNode.Accept(GlobVisitor globber, GlobVisitorContext context)
   at Cake.Core.IO.Globbing.GlobVisitor.Walk(GlobNode node, GlobberSettings settings)
   at Cake.Core.IO.Globber.Match(GlobPattern pattern, GlobberSettings settings)
   at Cake.Core.IO.GlobberExtensions.Match(IGlobber globber, GlobPattern pattern)
   at Cake.Common.IO.GlobbingAliases.GetFiles(ICakeContext context, GlobPattern pattern)
   ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions