Skip to content

Commit 6c5d46d

Browse files
committed
Add Referenced Affixes - Metadata Format section
1 parent 28f2d93 commit 6c5d46d

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

docs/for-contributors/Generator/generator-mods.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
(TODO: Explain what mods are)
44

55
(TODO: Add a section for each mod and explain what they do at a high level. Also provide examples of the transformations done. Also link to where more information can be obtained (source code, test cases))
6+
7+
### Affix Categories
8+
9+
(TODO: Don't keep this as its own section, but for each mod, explain the affix categories that the mod adds. Provide examples on what the affixes look like and how they should be configured in `generator.json`)

docs/for-contributors/Generator/name-processing.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ In order, the parameters are:
294294
arguably cleaner to avoid leading or trailing underscores in affix values. If this does prove to be a problem,
295295
prefer updating the affix stripping code to be tolerant of extra underscores.
296296

297-
These parameters are all strings for simplicity when parsing.
297+
These parameters are all strings for simplicity when parsing. Additionally, the order of the attributes is significant:
298+
name affixes declared earlier in the attribute list represent name affixes closer to the inside of the name.
298299

299300
However, as a user of the name affix system, the utilities provided by `NameAffixer` should provide everything necessary
300301
for interacting with name affixes without interacting with the exact syntax node representation.
@@ -371,13 +372,24 @@ type's name in the IDE. For example, if vendor suffixes always moved to the end
371372
`PerformanceCounterDescriptionARMName` would become `PerformanceCounterDescriptionNameARM` and would not show up when
372373
autocompleting `PerformanceCounterDescriptionARM`.
373374

374-
### Affix Categories
375+
### Referenced Affixes - Metadata Format
375376

376-
(TODO: Exhaustively list each category being used in the generator. Explain which mods add the affix category. Provide examples on what the affixes look like. Provide recommendations on how each affix should be configured (i.e., should match the configuration used by `generator.json`).)
377+
Referenced affixes work the exact same as normal name affixes, but take advantage of C#'s nameof syntax.
377378

378-
(TODO: This overrides the previous todo. Don't list the affix categories. Just explain them. List them out in the generator-mods.md doc instead.)
379+
```cs
380+
public struct GamepadBinding;
381+
382+
[NameAffix("Prefix", "NestedStructParent", nameof(GamepadBinding))]
383+
public struct GamepadBindingInput;
384+
385+
[NameAffix("Prefix", "NestedStructParent", nameof(GamepadBindingInput))]
386+
public struct GamepadBindingInputAxis;
387+
```
379388

380-
(TODO: Edit. Just explain them as part of the syntax section for Name Affixes above.)
389+
Limitation: Only simple references are allowed because references are resolved manually by `PrettifyNames`. For example,
390+
`nameof(GamepadBinding.Member)` will not work because member access expressions are not handled. Currently, only
391+
identifiers that exist in the current scope or parent scope can be referenced. That said, this should be enough for most
392+
use cases.
381393

382394
## Symbol-based Renamer
383395

0 commit comments

Comments
 (0)