From 3f4b56dc30dbf96869a0145d7b346b4e8a22ddd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Sun, 17 Feb 2019 20:42:18 -0500 Subject: [PATCH] Adjust for null _environment.ReferencePath --- .../SourceGeneratorEngine.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Uno.SourceGeneration.Engine.Shared/SourceGeneratorEngine.cs b/src/Uno.SourceGeneration.Engine.Shared/SourceGeneratorEngine.cs index bc1a746..e9bc0d6 100644 --- a/src/Uno.SourceGeneration.Engine.Shared/SourceGeneratorEngine.cs +++ b/src/Uno.SourceGeneration.Engine.Shared/SourceGeneratorEngine.cs @@ -65,9 +65,12 @@ namespace Uno.SourceGeneration.Host Microsoft.CodeAnalysis.Host.Mef.MefHostServices.DefaultHost.ToString(); // Pre-load known references - foreach (var reference in _environment.ReferencePath) + if (_environment.ReferencePath != null) { - _metadataResolver.ResolveReference(Path.GetFileName(reference), Path.GetDirectoryName(reference), new MetadataReferenceProperties()); + foreach (var reference in _environment.ReferencePath) + { + _metadataResolver.ResolveReference(Path.GetFileName(reference), Path.GetDirectoryName(reference), new MetadataReferenceProperties()); + } } } @@ -272,13 +275,16 @@ namespace Uno.SourceGeneration.Host var solution = ws2.CurrentSolution.AddProject(pi); var project = solution.GetProject(pi.Id); - foreach(var reference in _environment.ReferencePath) + if (_environment.ReferencePath != null) { - var metadataRefs = _metadataResolver.ResolveReference(Path.GetFileName(reference), Path.GetDirectoryName(reference), new MetadataReferenceProperties()); - - foreach (var metadataRef in metadataRefs) + foreach (var reference in _environment.ReferencePath) { - project = project.AddMetadataReference(metadataRef); + var metadataRefs = _metadataResolver.ResolveReference(Path.GetFileName(reference), Path.GetDirectoryName(reference), new MetadataReferenceProperties()); + + foreach (var metadataRef in metadataRefs) + { + project = project.AddMetadataReference(metadataRef); + } } }