[Bug] CustomAttribute in Declaration
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 890
- Avg merge
- 2h 11m
- Merged PRs (30d)
- 10
Description
**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;
}
}
```
3. 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
```
4. Generate the document in DocFx.
5. 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](https://github.com/hirohiroj3cub/DocFx_DisplayMyAttribute)
(I'm not very familiar with English, GitHub, or DocFx, so please point out any mistakes)
Contributor guide
Assessment
This issue has not been assessed yet.