ViewPaths { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Test.WebApp/MvcApplication.cs:
--------------------------------------------------------------------------------
1 | using System.Web;
2 | using System.Web.Mvc;
3 | using System.Web.Routing;
4 | using StackExchange.Precompilation;
5 | using Test.WebApp.Controllers;
6 |
7 | namespace Test.WebApp
8 | {
9 | public static class MvcApplicationInitializer
10 | {
11 | public static void PreApplicationStart() =>
12 | System.Web.UI.PageParser.DefaultApplicationBaseType = typeof(MvcApplication);
13 | }
14 |
15 | public class MvcApplication : HttpApplication
16 | {
17 | public static bool IsDebug =>
18 | #if DEBUG
19 | true;
20 | #else
21 | false;
22 | #endif
23 |
24 | protected void Application_Start()
25 | {
26 | AreaRegistration.RegisterAllAreas();
27 | GlobalFilters.Filters.Add(new HandleErrorAttribute());
28 |
29 | RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
30 | RouteTable.Routes.MapRoute(
31 | name: "Default",
32 | url: "{controller}/{action}/{id}",
33 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
34 | );
35 |
36 | ViewEngines.Engines.Clear();
37 | #if !DEBUG
38 | // use precompiled engine first (supports some C# 6),
39 | ViewEngines.Engines.Add(new PrecompiledViewEngine(typeof(HomeController).Assembly, typeof(ExternalViews).Assembly));
40 | #endif
41 | // fallback to RoslynRazorViewEngine (RazorViewEngine doesn't support C# 6).
42 | ViewEngines.Engines.Add(new RoslynRazorViewEngine() { UseCompilationModules = true });
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Test.WebApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Web;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("Test.WebApp")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("Test.WebApp")]
14 | [assembly: AssemblyCopyright("Copyright © 2015")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("09bb37e2-0d7e-472d-b74c-aa02018c89c6")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Revision and Build Numbers
34 | // by using the '*' as shown below:
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: PreApplicationStartMethod(typeof(Test.WebApp.MvcApplicationInitializer), nameof(Test.WebApp.MvcApplicationInitializer.PreApplicationStart))]
38 |
39 |
--------------------------------------------------------------------------------
/Test.WebApp/Test.WebApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PackageReference
6 | Debug
7 | AnyCPU
8 |
9 |
10 | 2.0
11 | {5B0105A4-256B-4A88-852C-6F5E9D185515}
12 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
13 | Library
14 | Properties
15 | Test.WebApp
16 | Test.WebApp
17 | net462
18 | v4.6.2
19 | false
20 | true
21 |
22 |
23 |
24 |
25 | ..\
26 |
27 |
28 | win
29 | false
30 |
31 |
32 | true
33 | full
34 | false
35 | bin\
36 | DEBUG;TRACE
37 | prompt
38 | 4
39 |
40 |
41 | pdbonly
42 | true
43 | bin\
44 | TRACE
45 | prompt
46 | 4
47 |
48 |
49 |
50 | {3C0A90F1-B19E-4305-AB71-3CD31C7D0F4D}
51 | StackExchange.Precompilation
52 |
53 |
54 |
55 | {2ba24772-f7b0-4652-a430-2f4c2262e882}
56 | Test.WebApp.ExternalViews
57 |
58 |
59 | {5fcaecc3-787b-473f-a372-783d0c235190}
60 | Test.Module
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | True
87 |
88 |
89 |
90 |
91 |
92 |
93 | $(SolutionDir)StackExchange.Precompilation.Build\bin\$(Configuration)\$(TargetFramework)\
94 |
95 | true
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Home/ExcludedLayout.cshtml:
--------------------------------------------------------------------------------
1 |
2 | @{
3 | Layout = "~/Views/Shared/_Layout.Excluded.cshtml";
4 | }
5 |
6 | ExcludedLayout
7 |
8 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Home/Index.Mobile.cshtml:
--------------------------------------------------------------------------------
1 | @model SampleModel
2 | @{
3 | ViewBag.Title = "Test Page";
4 | }
5 | Mobile Precompiled View Paths:
6 |
7 | @foreach (var path in Model.ViewPaths)
8 | {
9 | - @path
10 | }
11 |
12 |
13 | @Html.EditorForModel()
14 |
15 | @Helpers.Test()
16 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 | @model SampleModel
2 | @{
3 | ViewBag.Title = "Test Page";
4 | }
5 | Precompiled View Paths:
6 |
7 | @foreach (var path in Model.ViewPaths)
8 | {
9 | - @path
10 | }
11 |
12 |
13 | @Html.EditorForModel()
14 | @Html.Partial("../Other/../Other/RelativePartial")
15 | @Helpers.Test()
16 |
17 | @if (!MvcApplication.IsDebug)
18 | {
19 | @Html.Partial("ExternalPartial");
20 | }
21 |
22 | @{
23 | // c# 7 features
24 |
25 |
26 | (string title, string url) GetTitle() => ("ValueTuple", "`2");
27 | @GetTitle().Item1
28 | }
--------------------------------------------------------------------------------
/Test.WebApp/Views/Other/RelativePartial.cshtml:
--------------------------------------------------------------------------------
1 | RelativePartial.cshtml
2 | @{
3 | @*
4 | code bellow is a repro case for a Razer parser errors, that were only caught
5 | in RoslynRazorViewEngine but not during precompilation...
6 |
7 | to repro use `@foreach` instead of `foreach`
8 | *@
9 |
10 | foreach(var x in new []{1,2,3})
11 | {
12 | @:@x,
13 | }
14 | }
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/EditorTemplates/SampleModel.Mobile.cshtml:
--------------------------------------------------------------------------------
1 | @model Test.WebApp.Models.SampleModel
2 |
3 | EditorTemplates.Mobile
4 | @using (Html.BeginForm())
5 | {
6 | @Html.AntiForgeryToken()
7 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/EditorTemplates/SampleModel.cshtml:
--------------------------------------------------------------------------------
1 | @model Test.WebApp.Models.SampleModel
2 |
3 | EditorTemplates
4 | @using (Html.BeginForm())
5 | {
6 | @Html.AntiForgeryToken()
7 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/EditorTemplates/String.cshtml:
--------------------------------------------------------------------------------
1 | @model System.String
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/_Footer.Mobile.cshtml:
--------------------------------------------------------------------------------
1 | @model DateTime
2 |
5 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/_Footer.cshtml:
--------------------------------------------------------------------------------
1 | @model DateTime
2 |
5 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/_Layout.Excluded.cshtml:
--------------------------------------------------------------------------------
1 | Layout
2 |
3 | @RenderBody()
4 |
5 | /Layout
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/_Layout.Mobile.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | @ViewBag.Title - Test.WebApp - Mobile
6 |
7 |
8 | Mobile
9 |
10 |
11 | @RenderBody()
12 |
13 |
14 | @Html.Partial("_Footer", DateTime.Now)
15 | @Html.Partial("~/Content/PartialExternalContent.cshtml")
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/_Layout.Overridden.cshtml:
--------------------------------------------------------------------------------
1 | OVERRIDDDDDEN
2 | @ViewBag.Title - Test.WebApp
3 | @RenderBody()
4 | /OVERRIDDDDDEN
5 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | @ViewBag.Title - Test.WebApp
6 |
7 |
8 |
9 | @RenderBody()
10 |
11 |
12 | @Html.ActionLink("Overridden layout", "IndexOverridden", new { controller = "Home".Dump() })
13 | @Html.ActionLink("Excluded layout", "ExcludedLayout", new { controller = "Home" })
14 | @Html.Partial("_Footer", DateTime.Now)
15 | @Html.Partial("~/Content/PartialExternalContent.cshtml")
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Test.WebApp/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "~/Views/Shared/_Layout.cshtml";
3 | }
4 | _ViewStart
5 |
6 |
--------------------------------------------------------------------------------
/Test.WebApp/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 | image: Visual Studio 2017
3 | assembly_info:
4 | patch: true
5 | file: '**\AssemblyInfo.*'
6 | assembly_version: $(semver)
7 | assembly_file_version: $(semver).{build}
8 | assembly_informational_version: '{version}'
9 | init:
10 | - git config --global core.autocrlf input
11 | install:
12 | - ps: >-
13 | set -name semver -scope global -value (get-content .\semver.txt)
14 |
15 | $env:semver = $semver
16 |
17 | if ("$env:appveyor_repo_tag_name" -ne "releases/$semver") {
18 | $env:package_suffix = "-alpha$env:appveyor_build_number" }
19 |
20 | update-appveyorbuild -Version "$env:semver$env:package_suffix"
21 | nuget:
22 | disable_publish_on_pr: true
23 | build_script:
24 | - ps: .\BuildAndPack.ps1 -VersionSuffix "$env:package_suffix" -GitCommitId "$env:appveyor_repo_commit" -MsBuildArgs @(, "/logger:C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll") -CIBuild
25 | skip_branch_with_pr: true
26 | skip_tags: false
27 | skip_commits:
28 | files:
29 | - '**/*.md'
30 | artifacts:
31 | - path: packages/obj/*.nupkg
32 | deploy:
33 | - provider: NuGet
34 | name: alpha
35 | on:
36 | branch: master
37 | server: https://www.myget.org/F/stackoverflow/api/v2
38 | api_key:
39 | secure: P/UHxq2DEs0GI1SoDXDesHjRVsSVgdywz5vmsnhFQQY5aJgO3kP+QfhwfhXz19Rw
40 | symbol_server: https://www.myget.org/F/stackoverflow/symbols/api/v2/package
41 | - provider: NuGet
42 | name: release
43 | on:
44 | appveyor_repo_tag: true
45 | server: https://www.myget.org/F/stackoverflow/api/v2
46 | api_key:
47 | secure: P/UHxq2DEs0GI1SoDXDesHjRVsSVgdywz5vmsnhFQQY5aJgO3kP+QfhwfhXz19Rw
48 | symbol_server: https://www.myget.org/F/stackoverflow/symbols/api/v2/package
49 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Stack Exchange
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/semver.txt:
--------------------------------------------------------------------------------
1 | 5.1.0
2 |
--------------------------------------------------------------------------------