Skip to content
This repository was archived by the owner on Jul 21, 2022. It is now read-only.

Commit 01b0873

Browse files
author
Michal Ciechan
committed
Fixing #6 UseRazorComponentsRuntimeCompilation ReadAllFiles NRE
1 parent aab433f commit 01b0873

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/RazorComponentsPreview/Razor/RuntimeComponentsGenerator.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ @namespace Test
8484
files.Insert(0, razorImportsFile);
8585

8686
//hack for to get dependencies from Test
87-
var item = files.SingleOrDefault(item => item.FilePath.Contains("App.razor"));
88-
var fixedAPPcontent = item.Content.Replace("@typeof(", "@typeof(Test.").Replace("Program", "Counter"); //Todo change name "Counter" to dynamic type from Test Assemebly
89-
files.Remove(item);
90-
files.Add((item.FilePath, fixedAPPcontent));
87+
var appRazorItem = files.SingleOrDefault(item => item.FilePath.Contains("App.razor"));
9188

89+
if (appRazorItem != default)
90+
{
91+
var fixedAPPcontent = appRazorItem.Content.Replace("@typeof(", "@typeof(Test.").Replace("Program", "Counter"); //Todo change name "Counter" to dynamic type from Test Assemebly
92+
files.Remove(appRazorItem);
93+
files.Add((appRazorItem.FilePath, fixedAPPcontent));
94+
}
9295

9396
return files;
9497
}

0 commit comments

Comments
 (0)