You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -38,17 +38,57 @@ This section explains how names flow through the SilkTouch generator pipeline.
38
38
- For example, `[NativeName]` is kept and `[NameAffix]` is removed during the `StripAttributes` mod.
39
39
- Tip: Disabling the `StripAttributes` mod can be helpful for debugging unwanted outputs.
40
40
41
+
## Test cases
42
+
43
+
The behavior for the name processing pipeline is heavily unit tested.
44
+
Please refer to the unit tests for the corresponding section of the codebase to see detailed examples of how
45
+
different inputs are transformed into their outputs.
46
+
41
47
## PrettifyNames
42
48
43
49
As seen above, `PrettifyNames` is the mod central to name processing.
44
50
45
51
The goal of this mod is to take all of the names from the generated bindings and transform them in bulk.
46
52
This keeps other mods performant and simple, as renaming identifiers is a costly operation
47
53
that involves searching the entire project for references to that identifier.
48
-
Despite this, `PrettifyNames` also has the goal of remaining dumb and does this
49
-
by relying on the generator config for all major decisions.
50
54
51
-
(TODO: Explain how other mods and the user are supposed to interact with PrettifyNames)
55
+
Despite this, `PrettifyNames` also has the goal of remaining dumb and straightforward.
56
+
It relies on the generator config for API-specific decisions (eg: removing/reordering affixes, overrides)
57
+
and other mods for API-specific annotations (eg: API-specific prefix/suffix conventions).
58
+
The rest of the processing (eg: prettification), while complex, is done uniformly.
59
+
60
+
This allows `PrettifyNames` to focus strictly on the common case, while edge cases are handled elsewhere.
61
+
In practice, this works fairly well. Even though the configuration options are limited mostly to how affixes are
62
+
handled, affixes are usually where native APIs differ in their naming conventions. Other differences fall outside
63
+
the common case and are therefore handled by the generator user or by other mods.
64
+
65
+
Furthermore, to keep `PrettifyNames` simple and linear, each step takes the output of the previous step,
66
+
with no interweaving of logic.
67
+
68
+
`PrettifyNames` works as follows:
69
+
70
+
1. All current source code is scraped to gather name information.
71
+
2. The names are transformed by a series of name processors.
72
+
3. Symbols corresponding to all transformed names are gathered.
73
+
4. A symbol-based renamer is used to replace all references to those names with their new versions.
74
+
5. Document file names are renamed using the transformed names.
75
+
76
+
At time of writing, these are the name processors in use:
77
+
```cs
78
+
varnameProcessors=newINameProcessor[]
79
+
{
80
+
newHandleOverridesProcessor(cfg.NameOverrides), // Overrides are user configurable
81
+
newStripAffixesProcessor(visitor),
82
+
newPrettifyProcessor(namePrettifier), // Acronym threshold is user configurable
83
+
newReapplyAffixesProcessor(visitor, namePrettifier, cfg.Affixes), // Affix reapplication is user configurable
84
+
newPrefixIfStartsWithNumberProcessor(),
85
+
newResolveConflictsProcessor(visitor, logger),
86
+
newOutputFinalNamesProcessor(),
87
+
newRemoveUnmodifiedFinalNamesProcessor(),
88
+
};
89
+
```
90
+
91
+
For specifics on how these processors and other steps work, it is best to refer to the `PrettifyNames` source code.
52
92
53
93
## Name Splitting
54
94
@@ -69,3 +109,7 @@ by relying on the generator config for all major decisions.
69
109
### Affix Categories
70
110
71
111
(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`).)
112
+
113
+
## Symbol-based Renamer
114
+
115
+
(TODO: Explain how the symbol-based renamer works and why `SymbolFinder.FindReferencesAsync` is not used.)
0 commit comments