Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug in referencing master page from embedded resource #1754

Merged
merged 2 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
});
}
}
}
Loading