diff --git a/Directory.Packages.props b/Directory.Packages.props
index 83ffb23..e975d76 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -17,4 +17,4 @@
-
\ No newline at end of file
+
diff --git a/Examples/AltaSoft.DomainPrimitives.Demo/AltaSoft.DomainPrimitives.Demo.csproj b/Examples/AltaSoft.DomainPrimitives.Demo/AltaSoft.DomainPrimitives.Demo.csproj
index f674d53..cef6361 100644
--- a/Examples/AltaSoft.DomainPrimitives.Demo/AltaSoft.DomainPrimitives.Demo.csproj
+++ b/Examples/AltaSoft.DomainPrimitives.Demo/AltaSoft.DomainPrimitives.Demo.csproj
@@ -17,9 +17,9 @@
-
-
-
+
+
+
diff --git a/Examples/DomainPrimitivesDemo/DomainPrimitivesDemo.csproj b/Examples/DomainPrimitivesDemo/DomainPrimitivesDemo.csproj
index c1e8c05..7065cfa 100644
--- a/Examples/DomainPrimitivesDemo/DomainPrimitivesDemo.csproj
+++ b/Examples/DomainPrimitivesDemo/DomainPrimitivesDemo.csproj
@@ -8,10 +8,8 @@
false
-
-
-
+
diff --git a/tests/AltaSoft.DomainPrimitives.Generator.Tests/TestHelpers.cs b/tests/AltaSoft.DomainPrimitives.Generator.Tests/TestHelpers.cs
index 7408059..44fbda4 100644
--- a/tests/AltaSoft.DomainPrimitives.Generator.Tests/TestHelpers.cs
+++ b/tests/AltaSoft.DomainPrimitives.Generator.Tests/TestHelpers.cs
@@ -26,15 +26,26 @@ internal static (ImmutableArray Diagnostics, List Output, Ge
]);
var syntaxTree = CSharpSyntaxTree.ParseText(source, parseOptions);
- var references = AppDomain.CurrentDomain.GetAssemblies()
- .Where(x => !x.IsDynamic && !string.IsNullOrWhiteSpace(x.Location))
- .Select(x => MetadataReference.CreateFromFile(x.Location))
+
+ // Use the full set of assemblies the runtime resolved for this process (via its deps.json),
+ // rather than AppDomain.CurrentDomain.GetAssemblies(), which only reflects whichever assemblies
+ // happen to already be JIT-loaded. The latter is non-deterministic across environments and can
+ // silently omit assemblies like System.ObjectModel (home of TypeConverterAttribute), causing
+ // sporadic compile errors depending on process/load-order, not on anything about the source under test.
+ var trustedAssemblyPaths = ((string?)AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES"))
+ ?.Split(Path.PathSeparator) ?? [];
+
+ var referencePaths = trustedAssemblyPaths
.Concat([
- MetadataReference.CreateFromFile(typeof(T).Assembly.Location),
- MetadataReference.CreateFromFile(typeof(IDomainValue<>).Assembly.Location),
- MetadataReference.CreateFromFile(typeof(System.ComponentModel.DataAnnotations.DisplayAttribute).Assembly.Location)
+ typeof(T).Assembly.Location,
+ typeof(IDomainValue<>).Assembly.Location,
+ typeof(System.ComponentModel.DataAnnotations.DisplayAttribute).Assembly.Location
])
- .Concat(assembliesToImport.Select(a => MetadataReference.CreateFromFile(a.Location)));
+ .Concat(assembliesToImport.Select(a => a.Location))
+ .Where(p => !string.IsNullOrWhiteSpace(p))
+ .Distinct(StringComparer.OrdinalIgnoreCase);
+
+ var references = referencePaths.Select(p => (MetadataReference)MetadataReference.CreateFromFile(p));
var compilation = CSharpCompilation.Create(
"generator_Test",