Skip to content

Commit

Permalink
No depedency to System.CodeDom when targetting .net 8.0
Browse files Browse the repository at this point in the history
- CodeDom complilation cannot target .net core
- BatchCompiler.cs contains the code to complile with codedom and/or roslyn
  • Loading branch information
bounav committed Jan 29, 2024
1 parent d9ce0dc commit b0349d7
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 358 deletions.
3 changes: 0 additions & 3 deletions src/Castle.MonoRail.Views.Spark/SparkViewFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
using Castle.MonoRail.Views.Spark.Wrappers;
using Spark.Bindings;
using Spark.Compiler;
using Spark.Compiler.CodeDom;
using Spark.Compiler.Roslyn;
using Spark.Parser;
using Spark.Parser.Syntax;

namespace Castle.MonoRail.Views.Spark
Expand Down
3 changes: 2 additions & 1 deletion src/Spark.JsTests/Generate.ashx.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Copyright 2008-2009 Louis DeJardin - http://whereslou.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,7 +18,7 @@
using System.Web;
using System.Web.Services;
using Spark.Bindings;
using Spark.Compiler.Roslyn;
using Spark.Compiler;
using Spark.FileSystem;
using Spark.Parser;
using Spark.Parser.Syntax;
Expand Down
1 change: 0 additions & 1 deletion src/Spark.Python/Compiler/PythonViewCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Linq;
using System.Text;
using Spark.Compiler;
using Spark.Compiler.CodeDom;
using Spark.Compiler.CSharp.ChunkVisitors;
using GeneratedCodeVisitor=Spark.Python.Compiler.ChunkVisitors.GeneratedCodeVisitor;
using GlobalFunctionsVisitor=Spark.Python.Compiler.ChunkVisitors.GlobalFunctionsVisitor;
Expand Down
1 change: 0 additions & 1 deletion src/Spark.Ruby/Compiler/RubyViewCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Linq;
using System.Text;
using Spark.Compiler;
using Spark.Compiler.CodeDom;
using Spark.Ruby.Compiler.ChunkVisitors;
using BaseClassVisitor = Spark.Compiler.CSharp.ChunkVisitors.BaseClassVisitor;

Expand Down
2 changes: 1 addition & 1 deletion src/Spark.Web.Mvc.Ruby.Tests/HtmlHelperExtensionsTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System.Web.Routing;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Spark.Compiler.Roslyn;
using Spark.Compiler;
using Spark.FileSystem;
using Spark.Web.Mvc.Extensions;

Expand Down
1 change: 0 additions & 1 deletion src/Spark.Web.Mvc.Tests/SparkBatchCompilerTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using Spark.Compiler;
using Spark.Compiler.CodeDom;
using Spark.FileSystem;
using Spark.Web.Mvc.Extensions;
using Spark.Web.Mvc.Tests.Controllers;
Expand Down
36 changes: 18 additions & 18 deletions src/Spark.Web.Mvc/DynamicViewDataDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@

namespace Spark.Web.Mvc
{
public class DynamicViewDataDictionary : DynamicObject
{
private readonly ViewDataDictionary _viewData;
public class DynamicViewDataDictionary : DynamicObject
{
private readonly ViewDataDictionary _viewData;

public DynamicViewDataDictionary( ViewDataDictionary viewData )
{
_viewData = viewData;
}
public DynamicViewDataDictionary(ViewDataDictionary viewData)
{
_viewData = viewData;
}

public override bool TryGetMember( GetMemberBinder binder, out object result )
{
result = _viewData[binder.Name];
return true;
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
result = _viewData[binder.Name];
return true;
}

public override bool TrySetMember( SetMemberBinder binder, object value )
{
_viewData[binder.Name] = value;
return true;
}
}
public override bool TrySetMember(SetMemberBinder binder, object value)
{
_viewData[binder.Name] = value;
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.DependencyInjection;
using Spark.Bindings;
using Spark.Compiler;
using Spark.Compiler.CodeDom;
using Spark.Compiler.Roslyn;
using Spark.FileSystem;
using Spark.Parser;
Expand Down
31 changes: 15 additions & 16 deletions src/Spark.Web.Mvc/SparkView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class SparkView : SparkViewBase, IViewDataContainer, ITextWriter
private string _siteRoot;
private ViewDataDictionary _viewData;
private ViewContext _viewContext;
private dynamic _viewBag;
private dynamic _viewBag;

public TempDataDictionary TempData => ViewContext.TempData;

Expand All @@ -52,19 +52,19 @@ public ViewDataDictionary ViewData
set { SetViewData(value); }
}

public dynamic ViewBag
{
get
{
if( _viewBag == null )
SetViewBag( new DynamicViewDataDictionary(ViewData) );
return _viewBag;
}
}
public dynamic ViewBag
{
get
{
if( _viewBag == null )
SetViewBag(new DynamicViewDataDictionary(ViewData));
return _viewBag;
}
}

public ViewContext ViewContext
{
get { return _viewContext; }
get => _viewContext;
set { SetViewContext(value); }
}

Expand All @@ -73,10 +73,10 @@ protected virtual void SetViewData(ViewDataDictionary viewData)
_viewData = viewData;
}

protected virtual void SetViewBag( DynamicViewDataDictionary viewBag )
{
_viewBag = viewBag;
}
protected virtual void SetViewBag(DynamicViewDataDictionary viewBag)
{
_viewBag = viewBag;
}

protected virtual void SetViewContext(ViewContext viewContext)
{
Expand Down Expand Up @@ -135,7 +135,6 @@ public string SiteResource(string path)
return ResourcePathManager.GetResourcePath(SiteRoot, path);
}


public void Render(ViewContext viewContext, TextWriter writer)
{
var wrappedViewContext = new ViewContextWrapper(viewContext, this);
Expand Down
10 changes: 5 additions & 5 deletions src/Spark.Web.Mvc/SparkViewFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,17 @@ private static string RemoveSuffix(string value, string suffix)

ViewEngineResult IViewEngine.FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache)
{
return FindPartialView(controllerContext, partialViewName, useCache);
return this.FindPartialView(controllerContext, partialViewName, useCache);
}

ViewEngineResult IViewEngine.FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
{
return FindView(controllerContext, viewName, masterName, useCache);
return this.FindView(controllerContext, viewName, masterName, useCache);
}

void IViewEngine.ReleaseView(ControllerContext controllerContext, IView view)
{
ReleaseView(controllerContext, view);
this.ReleaseView(controllerContext, view);
}

#endregion
Expand All @@ -355,8 +355,8 @@ void IViewEngine.ReleaseView(ControllerContext controllerContext, IView view)

IViewFolder IViewFolderContainer.ViewFolder
{
get => Engine.ViewFolder;
set => Engine.ViewFolder = value;
get => this.Engine.ViewFolder;
set => this.Engine.ViewFolder = value;
}

#endregion
Expand Down
2 changes: 0 additions & 2 deletions src/Spark.Web.Tests/Compiler/CSharpViewCompilerTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

using System.Collections.Generic;
using NUnit.Framework;
using Spark.Compiler.CodeDom;
using Spark.Compiler.CSharp;
using Spark.Compiler.Roslyn;
using Spark.Tests;
using Spark.Tests.Models;
using Spark.Tests.Stubs;
Expand Down
2 changes: 0 additions & 2 deletions src/Spark.Web.Tests/Compiler/VisualBasicViewCompilerTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Spark.Compiler.CodeDom;
using Spark.Compiler.Roslyn;
using Spark.Compiler.VisualBasic;
using Spark.Tests;
using Spark.Tests.Models;
Expand Down
Loading

0 comments on commit b0349d7

Please sign in to comment.