Code Monkey home page Code Monkey logo

Comments (8)

mathiasi avatar mathiasi commented on September 22, 2024

Only workaround I could think of was

DotNet.Test("*Test.csproj") with
{
    DisplayName = "Dotnet Test",
    TestRunTitle = "Title",
    Arguments = "--no-build --configuration Release --collect \"Code coverage\"",
    Inputs = new()
    {
        { "ContinueOnError", parameters["myBool"] }
    }
}

but this looks less ideal.

from sharpliner.

premun avatar premun commented on September 22, 2024

Hey,
Thanks for opening this issue. I agree that this is a very useful feature and should be supported. Unfortunately, I think it will require quite a bit of work as technically a variable can be put in place of basically anything. I think it might have a solution where we create a wrapper type that could be "T or expression" but I will have to do some experiments to verify it can be done.

I will get back to you soon about this.

from sharpliner.

mathiasi avatar mathiasi commented on September 22, 2024

I was also thinking a wrapper would be needed. Maybe something like Conditioned. I did notice also that the following syntax didn't seem to be supported either:

- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: test
    testRunTitle: "Title"
    projects: |
      *.Test.csproj
    ${{ if eq(parameters.myBool, true) }}:  
      arguments: 'some arguments'
    ${{ if eq(parameters.myBool, false) }}: 
      arguments: 'some other arguments'

Maybe one solution could cover both scenarios

from sharpliner.

premun avatar premun commented on September 22, 2024

Once you're in the Dictionary (like in inputs), this is actually possible:

StepTemplate("template1.yaml", new()
{
    { "some", "value" },
    {
        If.IsPullRequest,
        new TemplateParameters()
        {
            { "pr", true }
        }
    },
    { "other", 123 },
}),

(from https://github.com/sharpliner/sharpliner/blob/main/docs/AzureDevOps/DefinitionReference.md#conditioned-expressions)

from sharpliner.

mathiasi avatar mathiasi commented on September 22, 2024

Ah okay thanks! Though my key reason for using Sharpliner is to avoid dealing with yaml in the first place :D So I thought it could be cool if it was possible in another manner.

from sharpliner.

premun avatar premun commented on September 22, 2024

I agree completely.

I think we will end up wrapping all properties in a Conditioned<>, yeah. For instance, now we have some like that already and some not.

For instance it's possible to do:

{
    Pool = If..
}

But it wouldn't be possible for ContinueOnError. So there is some debt in this where probably everything should be a Conditioned<>. We could then make variable/parameter references (or expressions) implicitly cast into this as well, producing a string ${{ parameter.foo }}.

However, there's one more angle to this - #122. This issue would mean wrapping all properties again so that we create a dictionary behind that we serialize. This would mean your C# and YAML would be ordered how you want and not how we decide in Sharpliner. So this is another one where we might potentially have to change dozens of properties. I need to consider both and whether it makes sense to do them together. But your issue has preference 100%. The order is not so important.

from sharpliner.

premun avatar premun commented on September 22, 2024

@mathiasi I was able to make this work using the Conditioned<> everywhere. However, I still think we have some missing spots, e.g. using generic expressions everywhere. Something like this:

    continueOnError: ${{ replace(parameters.someParameter, ' ', '') }}

But I think this should be possible to add with some new Expression() method...

from sharpliner.

mathiasi avatar mathiasi commented on September 22, 2024

That was quick! 😄 Unfortunately I won't have the chance to try it out until a in couple of weeks but I definitely will!

from sharpliner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.