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
Docs: Clarifies source generator ambiguities and disabling (#410) (#411)
Adds documentation explaining ambiguous reference issues caused by internal partial source-generated classes, details how to disable specific generators via MSBuild properties, and updates README navigation to source generator docs.
Copy file name to clipboardExpand all lines: README.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,3 +64,11 @@ car.Accelerate(42);
64
64
// This method verifies all mocks in the container
65
65
mocker.VerifyAll();
66
66
```
67
+
68
+
Documentation
69
+
=============
70
+
71
+
For more detailed documentation, including information about the built-in source generators that can automatically generate test boilerplate code, see the [docs folder](docs/).
72
+
73
+
-[AutoMocker API Reference](docs/Moq.AutoMock.md)
74
+
-[Source Generators](docs/SourceGenerators.md) - Learn about automatic code generation for constructor tests, options configuration, logging, and more
Copy file name to clipboardExpand all lines: docs/SourceGenerators.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,64 @@ var service = mocker.CreateInstance<MyService>();
108
108
109
109
[Learn more →](SourceGenerators/KeyedServicesExtensionGenerator.md)
110
110
111
+
## Important: Generated Classes Are Internal Partials
112
+
113
+
All extension classes created by these source generators are generated as **partial classes** with **internal visibility**. For example, the Keyed Services generator produces:
### Ambiguous Reference Issues with Multiple Test Projects
123
+
124
+
This design can cause **ambiguous method call errors** when multiple test projects reference each other and both have the source generators enabled. Since each project generates its own internal partial class with the same name and methods, projects that share visibility (e.g., via `InternalsVisibleTo` or project references) may see duplicate definitions.
125
+
126
+
**Example error:**
127
+
```
128
+
The call is ambiguous between the following methods or properties:
129
+
'Moq.AutoMock.AutoMockerKeyedServicesExtensions.WithKeyedService(...)' and
0 commit comments