[Bug] CustomAttribute in Declaration
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:
- Create a Unity Project.
- 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;
}
}
- 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
- Generate the document in DocFx.
- In the field declaration, [SerializeField],[Range(0, 100)], are displayed, but [MyCustom] is not.
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)
As a temporary workaround.
It can be resolved by adding empty constructor to MyCustomAttribute.
See #9688 for details.