diff --git a/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs b/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs index a914181549dbd141b535b8be668ae96c68419c3b..74576bc646b0fbbf72f20f7f55e442bb935b5e58 100644 --- a/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs +++ b/src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs @@ -485,7 +485,15 @@ private CompilationSet(VersionStamp version, ValueSource compilatio } var documentId = newProject.GetDocumentId(newTree); - Contract.Requires(documentId != null); + + // GetDocumentId will return null for #load'ed trees. + // TODO: Remove this check and add logic to fetch the #load'ed tree's + // Document once https://github.com/dotnet/roslyn/issues/5260 is fixed. + if (documentId == null) + { + Debug.Assert(newProject.Solution.Workspace.Kind == "Interactive"); + continue; + } map = map.SetItem(documentId, newTree); }