docfx icon indicating copy to clipboard operation
docfx copied to clipboard

[Bug] CustomAttribute in Declaration

Open hirohiroj3cub opened this issue 2 years ago • 1 comments

Describe the bug I am using DocFx for a Unity project. DocFx shows the Unity Attribute in the field's Declaration, but not my CustomAttribute. I also tried writing attributeRules in filterConfig but it did not work.

To Reproduce Steps to reproduce the behavior:

  1. Create a Unity Project.
  2. Add the following scripts.
using System;
using UnityEngine;

namespace MyNameSpace
{
    [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
    public class MyCustomAttribute : Attribute
    {

    }

    [Serializable]
    public class MyClass
    {
        [SerializeField, Range(0, 100), MyCustom]
        public int intField;
    }
}
  1. Create a DocFx project and configure docfx.json and filterConfig.yml as follows
{
  "metadata": [
    {
      "src": [
          {
            "src": "../DocFx_DisplayMyAttribute",
            "files": [
              "*.sln"
            ]
          }
      ],
      "filter": "filterConfig.yml",
      "dest": "api",
      "includePrivateMembers": false,
      "disableGitFeatures": false,
      "disableDefaultFilter": false,
      "noRestore": false,
      "namespaceLayout": "flattened",
      "memberLayout": "samePage",
      "EnumSortOrder": "alphabetic",
      "allowCompilationErrors": true
    }
  ],
  "build": {
    "globalMetadata": {
        "_appTitle": "DocFx_DisplayMyAttribute documentation",
        "_appFooter": "DocFx_DisplayMyAttribute documentation",
        "_enableSearch": true
    },
    "content": [
      {
        "files": [
          "api/**.yml",
          "api/index.md"
        ]
      },
      {
        "files": [
          "manuals/**.md",
          "manuals/**/toc.yml",
          "toc.yml",
          "*.md"
        ]
      }
    ],
    "resource": [
      {
        "files": [
          "images/**",
          "logo.svg",
          "favicon.ico"
        ]
      }
    ],
    "xref": [
        "https://normanderwan.github.io/UnityXrefMaps/xrefmap.yml"
    ],
    "xrefService": [
        "https://xref.docs.microsoft.com/query?uid={uid}"
    ],
    "output": "_site",
    "globalMetadataFiles": [],
    "fileMetadataFiles": [],
    "template":["default","templates/unity"],
    "postProcessors": [],
    "keepFileLink": false,
    "disableGitFeatures": false
  }
}
attributeRules:
- include:
    uidRegex: ^MyNameSpace
    type: Namespace
apiRules:
- include:
    uidRegex: ^MyNameSpace
    type: Namespace
- include:
    uidRegex: ^Global
    type: Namespace
- exclude:
    uidRegex: .*
    type: Namespace
  1. Generate the document in DocFx.
  2. In the field declaration, [SerializeField],[Range(0, 100)], are displayed, but [MyCustom] is not.

image

Expected behavior All Attributes must appear in the Declaration.

Context (please complete the following information):

  • OS: Windows 10
  • Docfx version: 2.70.4

Additional context We have placed a minimal project that reproduces this problem in the following repository. DocFx_DisplayMyAttribute

(I'm not very familiar with English, GitHub, or DocFx, so please point out any mistakes)

hirohiroj3cub avatar Sep 23 '23 01:09 hirohiroj3cub

As a temporary workaround. It can be resolved by adding empty constructor to MyCustomAttribute.

See #9688 for details.

filzrev avatar Feb 10 '24 01:02 filzrev