Skip to content

Duplication of custom operations #1775

Open

Description

@XomegaNet

First of all, neither CustomOperations nor SpecialCustomOperations are included in the json schema, which results in no Intellisense support in VS 2017, and makes them hard to work with.

We need to use conditional processing for XML content in various template files, but, while it works fine for our *proj files, it does not work for .config files out of the box. We had to add special operations for .config files to enable it as follows.

  "SpecialCustomOperations": {
    "**/*.config": {
      "operations": [
        {
          "type": "conditional",
          "configuration": {
            "actionableIf": [ "<!--#if" ],
            "actionableElse": [ "#else", "<!--#else" ],
            "actionableElseif": [ "#elseif", "<!--#elseif", "#elif", "<!--#elif" ],
            "endif": [ "#endif", "<!--#endif" ],
            "trim": "true",
            "wholeLine": "true",
            "actions": [ "fixPseudoNestedComments" ]
          }
        },
        {
          "type": "balancednesting",
          "configuration": {
            "startToken": "<!--",
            "realEndToken": "-->",
            "pseudoEndToken": "-- >",
            "id": "fixPseudoNestedComments",
            "resetFlag": "_TestResetFlag_"
          }
        }
      ]
    },...

However, we also have other files that contain XML with a different extension (*.xom). So, to enable conditional processing for those as well, we had to repeat the same configuration for the **/*.xom pattern, since I don't know how to specify the glob to cover multiple extensions. This results in unnecessary duplication, and bloats the template configuration.

It would be great if the operations could be defined separately under a unique name, and then just referenced by the special custom operations under the respective globs. In this case we would just reference the standard operation to apply it to any additional extensions. Please let me know if there is a better way to define such conditional processing without duplicating configurations.

Activity

  1. added
    triaged
    on Mar 20, 2020
  2. donJoseLuis commented on Mar 24, 2020

    @donJoseLuis

    Hello @XomegaNet , can you please confirm this remains something you're interested in?

  3. added
    need-customer-info
    and removed on Mar 24, 2020
  4. XomegaNet commented on Mar 24, 2020

    @XomegaNet
    Author

    Hi @donJoseLuis, yes, sure. Given the limitations of the glob patterns to cover multiple file extensions or any special cases, I think it's important to be able to define reusable configurations for operations to avoid bloating templates with duplicate operations.

  5. added
    need-discussion
    and removed
    need-customer-info
    on Apr 22, 2020
  6. Antoshjkee commented on Apr 23, 2020

    @Antoshjkee

    Exactly what I was looking for. Thank you, @donJoseLuis for bringing this up.

  7. added
    need-pm-discussion
    and removed
    need-discussion
    on Sep 14, 2020
  8. removed
    triaged
    on Apr 13, 2021
  9. KathleenDollard commented on Apr 13, 2021

    @KathleenDollard

    If we had some sort of an import feature, could that solve it? That would support some places in the ASP.NET templates where blocks of symbols are repeated in different templates (for auth).

    In my head it looks like

    "import" : "<fileName>",
    

    where the contents of the file would just be dumped into the current location.

    I have no idea how hard that would be to build, but it would allow reuse of any type of JSON fragment.

  10. removed
    need-pm-discussion
    on Apr 13, 2021
  11. added this to the Backlog milestone on Apr 19, 2021
  12. added
    triaged
    on Apr 19, 2021
  13. added
    Epic
    on Sep 1, 2021
  14. removed
    Epic
    on Sep 15, 2021
  15. added
    feature
    Priority:2
    area: authoring
    on May 16, 2023
  16. vlada-shubina commented on May 16, 2023

    @vlada-shubina
    Member

    As a possible solution, we discussed having shorter syntax for it as:

      "SpecialCustomOperations": {
          "inheritsFrom": {
                   "**/*.config" : "**/*.xml",
                   ...
          }
        },...
    

    where key value pairs are:

    • glob pattern that should inherit the configuration from existing
    • glob pattern to use (should exist either in standard configs or given in template.json)
  17. XomegaNet commented on May 19, 2023

    @XomegaNet
    Author

    @vlada-shubina I guess this approach should work. Thanks for looking into this.

  18. added
    triage:transfer-to-sdk
    on May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2area: authoringfeaturetriage:transfer-to-sdktriaged

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions