Skip to content

Commit

Permalink
Fixed bug in referencing master page from embedded resource (#1754)
Browse files Browse the repository at this point in the history
* Fixed issue with master page defines as embedded resource

* UI test added
  • Loading branch information
tomasherceg authored Jan 14, 2024
1 parent 5b6b6a3 commit cb8e675
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class EmbeddedMarkupFileLoader : IMarkupFileLoader
//load the file
using (Stream stream = assembly.GetManifestResourceStream(resourceName)!)
using (StreamReader sr = new StreamReader(stream))
return new MarkupFile(resourceName, resourceName, sr.ReadToEnd());
return new MarkupFile(virtualPath, virtualPath, sr.ReadToEnd());
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Samples/Common/DotVVM.Samples.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<None Remove="script\**" />
</ItemGroup>
<ItemGroup>
<Content Remove="Views\FeatureSamples\EmbeddedResourceControls\EmbeddedResourceMasterPage.dotmaster" />
<Content Remove="Views\FeatureSamples\ViewModules\ModuleControl.dotcontrol" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -98,6 +99,8 @@
<None Remove="Views\FeatureSamples\CustomPrimitiveTypes\RouteLink.dothtml" />
<None Remove="Views\FeatureSamples\CustomPrimitiveTypes\TextBox.dothtml" />
<None Remove="Views\FeatureSamples\CustomPrimitiveTypes\UsedInControls.dothtml" />
<None Remove="Views\FeatureSamples\EmbeddedResourceControls\EmbeddedResourceMasterPage.dotmaster" />
<None Remove="Views\FeatureSamples\EmbeddedResourceControls\PageWithEmbeddedResourceMasterPage.dothtml" />
<None Remove="Views\FeatureSamples\Formatting\AutoResourceInclusion.dothtml" />
<None Remove="Views\FeatureSamples\Formatting\AutoResourceInclusionMaster.dotmaster" />
<None Remove="Views\FeatureSamples\Formatting\ToStringGlobalFunctionBug.dothtml" />
Expand Down Expand Up @@ -193,6 +196,7 @@
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\FeatureSamples\EmbeddedResourceControls\EmbeddedResourceMasterPage.dotmaster" />
<EmbeddedResource Include="Views\FeatureSamples\ViewModules\LinkModuleControl.dotcontrol" />
<EmbeddedResource Include="Views\FeatureSamples\ViewModules\ModuleControl.dotcontrol" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DotVVM.Framework.ViewModel;
using DotVVM.Framework.Hosting;

namespace DotVVM.Samples.Common.ViewModels.FeatureSamples.EmbeddedResourceControls
{
public class EmbeddedResourceMasterPageViewModel : DotvvmViewModelBase
{

}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DotVVM.Framework.ViewModel;
using DotVVM.Framework.Hosting;

namespace DotVVM.Samples.Common.ViewModels.FeatureSamples.EmbeddedResourceControls
{
public class PageWithEmbeddedResourceMasterPageViewModel : EmbeddedResourceMasterPageViewModel
{

}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@viewModel DotVVM.Samples.Common.ViewModels.FeatureSamples.EmbeddedResourceControls.EmbeddedResourceMasterPageViewModel, DotVVM.Samples.Common

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h1>Embedded resource master page</h1>

<dot:ContentPlaceHolder ID="MainContent" />

</body>
</html>


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@viewModel DotVVM.Samples.Common.ViewModels.FeatureSamples.EmbeddedResourceControls.PageWithEmbeddedResourceMasterPageViewModel, DotVVM.Samples.Common
@masterPage embedded://DotVVM.Samples.Common/Views.FeatureSamples.EmbeddedResourceControls.EmbeddedResourceMasterPage.dotmaster

<dot:Content ContentPlaceHolderID="MainContent">

<p>Success</p>

</dot:Content>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Samples/Tests/Tests/Feature/EmbeddedResourceControlsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@ public void Feature_EmbeddedResourceControls_EmbeddedResourceControls()
AssertUI.Attribute(browser.First("input[type=button]"), "value", "This is text");
});
}

[Fact]
public void Feature_EmbeddedResourceControls_PageWithEmbeddedResourceMasterPage()
{
RunInAllBrowsers(browser => {
browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_EmbeddedResourceControls_PageWithEmbeddedResourceMasterPage);

AssertUI.TextEquals(browser.Single("p"), "Success");
});
}
}
}

0 comments on commit cb8e675

Please sign in to comment.