Precompile razor views

This is the initial code (beta) to support pre compiling razor views and providing a caching mechanism.
The intent for this implementation is to speed up first start by avoiding jitting of Razor and Roslyn when you don't ship .cs files in the app.

There are several followup issues (mostly RC or later):
1. Add functional tests - blocked on project references not working with meta programming
2. Support cache invalidation scenarios
2.1 Change files - supported
2.2 Delete files - supported
2.3 Delete/Change viewstart - not supported
2.4. File watcher support
2.5. Integrate with in memory cache - requires view start feature, and changes to memory cache.
3. Support not deloying razor files
4. CRC instead of MD5 hash (needs OSS approval), or alternatively Sha1 - Requires Razor changes
5. Diagnostics
5.1 for C# errors - supported
5.2 for Razor parsing errors - not supported (but VS will show up when you open the file).
6. Changes to Razor for exposing class name, namespace and hash from generator results.

How do you get a path of a file you enumerated? Build it up from the folder?

-----Original Message-----
From: "David Fowler" <notifications@github.com>
Sent: ‎9/‎24/‎2014 7:50 PM
To: "aspnet/Mvc" <Mvc@noreply.github.com>
Cc: "Yishai Galatzer" <yishai_galatzer@yahoo.com>
Subject: Re: [Mvc] Precompile razor views (#1178)

In src/Microsoft.AspNet.Mvc.Razor/Razor/RelativePath.cs:
> +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
> +
> +using System;
> +using System.Diagnostics.Contracts;
> +using System.IO;
> +using Microsoft.AspNet.FileSystems;
> +
> +namespace Microsoft.AspNet.Mvc.Razor
> +{
> +    internal static class RelativePath
> +    {
> +        private static string _trailingSlash = Path.DirectorySeparatorChar.ToString();
> +
> +        public static string GetRelativePath([NotNull] string basePath, [NotNull] IFileInfo file)
> +        {
> +            Contract.Assert(file.PhysicalPath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase));
It's wrong in general though. You should never use the PhysicalPath to make decisions. It might be null.
—
Reply to this email directly or view it on GitHub.=