public RoslynRazorView(RoslynRazorViewEngine viewEngine, ControllerContext controllerContext, string virtualPath, Type type, bool runViewStartPages) { _type = type; _virtualPath = virtualPath; _viewEngine = viewEngine; _runViewStartPages = runViewStartPages; _controllerContext = controllerContext; }
public RoslynRazorView(RoslynRazorViewEngine viewEngine, ControllerContext controllerContext, string virtualPath, Type type, bool runViewStartPages, string overridenLayoutPath) { _type = type; _virtualPath = virtualPath; _viewEngine = viewEngine; _runViewStartPages = runViewStartPages; _controllerContext = controllerContext; _overridenLayoutPath = overridenLayoutPath; }
/// <summary> /// Bear with me, so, in case a the view engine is being executed in a page targeting net45+ (including net46*) /// on a system that has net47+ installed, mscorlib contained referenced by BuildManager already /// contains ValueTuple, but due to this package referencing CodeAnalysis.Common, which also pulls in /// the System.ValueTuple package, that gets copied to /bin, and is therefore also picked up as a /// reference in build manager. /// This causes compilation.GetTypeByMetadataName("System.ValueTuple`2") to return null due to an /// ambigous match, resulting in the lovely CS8137 and CS8179 warnings, at runtime. /// The contents of the /bin directory get included due to the default <![CDATA[<add name="*" />]]> entry. /// <![CDATA[<remove name="*" />]]> doesn't work since it fails to load the assembly generated for global.asax.cs /// <![CDATA[<remove name="System.ValueTuple" />]]> doesn't work, since the wildcard takes preference /// https://referencesource.microsoft.com/#System.Web/Configuration/CompilationSection.cs,119d7e4aae57b4b6 /// <para /> /// So when this is the case, we need to remove the reference to the System.ValueTuple.dll /// </summary> /// <param name="compilation"></param> /// <returns></returns> public static CSharpCompilation MakeValueTuplesWorkWhenRunningOn47RuntimeAndTargetingNet45Plus(CSharpCompilation compilation) { var mscorlibAssembly = typeof(object).Assembly; var valueTupleAssembly = typeof(ValueTuple).Assembly; if (mscorlibAssembly != valueTupleAssembly && compilation.GetAssemblyOrModuleSymbol(RoslynRazorViewEngine.ResolveReference(mscorlibAssembly)) is IAssemblySymbol mscorlib) { compilation = compilation.RemoveReferences(RoslynRazorViewEngine.ResolveReference(valueTupleAssembly)); } return(compilation); }
public PrecompilationVirtualPathFactory(PrecompiledViewEngine precompiled = null, RoslynRazorViewEngine runtime = null) { _precompiled = precompiled; _runtime = runtime; }