diff --git a/BemtestNet.sln b/BemtestNet.sln index 1501911..cf623e0 100644 --- a/BemtestNet.sln +++ b/BemtestNet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication", "ConsoleApplication\ConsoleApplication.csproj", "{837EF80D-F368-4CDB-A820-360FEB63082B}" EndProject @@ -19,25 +19,43 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {837EF80D-F368-4CDB-A820-360FEB63082B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {837EF80D-F368-4CDB-A820-360FEB63082B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {837EF80D-F368-4CDB-A820-360FEB63082B}.Debug|x64.ActiveCfg = Debug|x64 + {837EF80D-F368-4CDB-A820-360FEB63082B}.Debug|x64.Build.0 = Debug|x64 {837EF80D-F368-4CDB-A820-360FEB63082B}.Release|Any CPU.ActiveCfg = Release|Any CPU {837EF80D-F368-4CDB-A820-360FEB63082B}.Release|Any CPU.Build.0 = Release|Any CPU + {837EF80D-F368-4CDB-A820-360FEB63082B}.Release|x64.ActiveCfg = Release|x64 + {837EF80D-F368-4CDB-A820-360FEB63082B}.Release|x64.Build.0 = Release|x64 {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Debug|x64.ActiveCfg = Debug|Any CPU + {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Debug|x64.Build.0 = Debug|Any CPU {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Release|Any CPU.ActiveCfg = Release|Any CPU {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Release|Any CPU.Build.0 = Release|Any CPU + {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Release|x64.ActiveCfg = Release|Any CPU + {D2EB2AAA-835F-454C-9AFA-26025D2E13DE}.Release|x64.Build.0 = Release|Any CPU {3C5830C5-377F-49F9-B0AC-F578860F5710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3C5830C5-377F-49F9-B0AC-F578860F5710}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C5830C5-377F-49F9-B0AC-F578860F5710}.Debug|x64.ActiveCfg = Debug|Any CPU + {3C5830C5-377F-49F9-B0AC-F578860F5710}.Debug|x64.Build.0 = Debug|Any CPU {3C5830C5-377F-49F9-B0AC-F578860F5710}.Release|Any CPU.ActiveCfg = Release|Any CPU {3C5830C5-377F-49F9-B0AC-F578860F5710}.Release|Any CPU.Build.0 = Release|Any CPU + {3C5830C5-377F-49F9-B0AC-F578860F5710}.Release|x64.ActiveCfg = Release|Any CPU + {3C5830C5-377F-49F9-B0AC-F578860F5710}.Release|x64.Build.0 = Release|Any CPU {A9128635-9F2E-468C-A309-858DC1BD63A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A9128635-9F2E-468C-A309-858DC1BD63A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9128635-9F2E-468C-A309-858DC1BD63A2}.Debug|x64.ActiveCfg = Debug|Any CPU + {A9128635-9F2E-468C-A309-858DC1BD63A2}.Debug|x64.Build.0 = Debug|Any CPU {A9128635-9F2E-468C-A309-858DC1BD63A2}.Release|Any CPU.ActiveCfg = Release|Any CPU {A9128635-9F2E-468C-A309-858DC1BD63A2}.Release|Any CPU.Build.0 = Release|Any CPU + {A9128635-9F2E-468C-A309-858DC1BD63A2}.Release|x64.ActiveCfg = Release|Any CPU + {A9128635-9F2E-468C-A309-858DC1BD63A2}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Benchmarks/Program.cs b/Benchmarks/Program.cs index cc634e4..efa4133 100644 --- a/Benchmarks/Program.cs +++ b/Benchmarks/Program.cs @@ -14,36 +14,32 @@ class Program static void Main(string[] args) { //GenerateBemJson(); - BenchmarkRazor(); + BenchmarkBemhtmlOnlyRender(); - Console.WriteLine("======"); + Console.WriteLine(@"STOP"); Console.ReadKey(); } - public static void RunRenderBenchmark() + public static void BenchmarkBemhtmlFullStack() { var bemhtml = new BemhtmlEngine(); var json = File.ReadAllText("test.bemjson.json"); - //object data = JObject.Parse(json); object data = GenerateBemJson(); - Console.WriteLine("==="); + Console.WriteLine("START"); var now = DateTime.Now; for (var i = 0; i < 1000; i++) { var task = bemhtml.Render(null, data); - // var task = BemhtmlEngine.Instance.Render(null, data); task.Wait(); } Console.WriteLine((DateTime.Now - now).TotalMilliseconds); - //Console.WriteLine(task.Result); - Console.ReadKey(); } - public static void RunRenderBenchmark2() + public static void BenchmarkBemhtmlOnlyRender() { var content = File.ReadAllText(@"C:\develop\bemtest-net\Benchmarks\Bem\desktop.bundles\default\default.bemhtml.js"); var template = new BemhtmlTemplate(content); @@ -82,7 +78,7 @@ public static void BenchmarkRazor() Console.WriteLine((DateTime.Now - now).TotalMilliseconds); } - public static void RunRenderBenchmark4() + public static void BenchmarkBemhtmlNoSerialize() { var content = File.ReadAllText(@"C:\develop\bemtest-net\Benchmarks\Bem\desktop.bundles\default2\default2.bemhtml.js"); var template = new BemhtmlTemplate(content); diff --git a/ConsoleApplication/Bemhtml.cs b/ConsoleApplication/Bemhtml.cs index c0024e9..7e71ad8 100644 --- a/ConsoleApplication/Bemhtml.cs +++ b/ConsoleApplication/Bemhtml.cs @@ -14,13 +14,16 @@ public class Bemhtml public Bemhtml(string template) { - const string wrapper = @" + Environment.SetEnvironmentVariable("EDGE_NODE_PARAMS", "--debug"); + const string wrapper = @" {0} var api = new BEMHTML({{}}); api.compile(function(match, once, wrap, elemMatch, block, elem, mode, mod, elemMod, def, tag, attrs, cls, js, bem, mix, content, replace, extend, oninit, xjstOptions, local, applyCtx, applyNext, apply) {{ {1}; }}); api.exportApply(exports); + debugger; + return function (data, callback) {{ callback(null, exports.apply(data));}}"; this.func = Edge.Func(string.Format(wrapper, Resources.bemhtml, template)); diff --git a/ConsoleApplication/ConsoleApplication.csproj b/ConsoleApplication/ConsoleApplication.csproj index dd2b9f8..9429966 100644 --- a/ConsoleApplication/ConsoleApplication.csproj +++ b/ConsoleApplication/ConsoleApplication.csproj @@ -31,6 +31,26 @@ prompt 4 + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + ..\packages\Edge.js.5.9.1\lib\EdgeJs.dll diff --git a/ConsoleApplication/templates.bemhtml.js b/ConsoleApplication/templates.bemhtml.js index 6e61275..f39d16e 100644 --- a/ConsoleApplication/templates.bemhtml.js +++ b/ConsoleApplication/templates.bemhtml.js @@ -22,6 +22,7 @@ block('icon')( tag()('span'), attrs()(function () { + debugger; var attrs = {}, url = this.ctx.url; if (url) attrs.style = 'background-image:url(' + url + ')'; diff --git a/DEBUG.md b/DEBUG.md new file mode 100644 index 0000000..ccb9f90 --- /dev/null +++ b/DEBUG.md @@ -0,0 +1,28 @@ +Как отлаживать код шаблонов +=========================== + +## Включение режима отладки +Пока что пока все в разработке вам надо где то в своем коде перед вызовом шаблонизации добавить выстяавление переменной окружения: +```csharp +Environment.SetEnvironmentVariable("EDGE_NODE_PARAMS", "--debug"); +``` + +## Дебаг в `Visual Studio` +Cтавим официальную [тулзу](https://github.com/Microsoft/nodejstools#readme) от MS. +Как ей пользоваться описывать не буду есть [видео](https://channel9.msdn.com/events/Visual-Studio/Connect-event-2015/801) + +Главная проблема - исходники не доступны, только контексты, но при неимении ничего возможность дебажить хотя бы контексты, может очень сильно помочь. + +## Дебаг в `node-inspector` +Это у меня не получилось заставить работать изза падени студии=( +Вот список подводных камней что я наткнулся: + - nodejs<=5.1 - edge.js содержит в себе всего несколько вресий node.js поэтому для того чтоб скачался именно нужный дебагер поставьте node 4 или 5.1 + - собирайте приложение в x64, если у вас машинка x64, при скачивании инспектор качает отладочные файлы для x64 платформы. Если не можете собрать свой проект в x64 нагуглите отладочные файлы под i386, я находил. + + После запуска приложения и попытке к нему приконектиться я получаю следующую ошибку: + ``` + The program '[0x1F00] ConsoleApplication.vshost.exe' has exited with code -1066598273 (0xc06d007f) 'Procedure not found'. + ``` + + При этом `node-inspector` выдает следующее: + https://github.com/bem-dot-net/system-web-bem/blob/debug/Windows%208.1%202016-07-04%2017-17-09.png diff --git a/System.Web.Bem/Configuration/BemConfiguration.cs b/System.Web.Bem/Configuration/BemConfiguration.cs index 6c82571..0b8fc01 100644 --- a/System.Web.Bem/Configuration/BemConfiguration.cs +++ b/System.Web.Bem/Configuration/BemConfiguration.cs @@ -35,6 +35,13 @@ public string Mapper get { return this["Mapper"] as string; } } + [ConfigurationProperty("Debug", DefaultValue = "false")] + public bool Debug + { + get { return (bool)this["Debug"]; } + } + + #endregion } } diff --git a/System.Web.Bem/Engine/BemhtmlEngine.cs b/System.Web.Bem/Engine/BemhtmlEngine.cs index 28db25a..a69b724 100644 --- a/System.Web.Bem/Engine/BemhtmlEngine.cs +++ b/System.Web.Bem/Engine/BemhtmlEngine.cs @@ -23,6 +23,11 @@ static BemhtmlEngine() { config = BemConfiguration.Load(); Instance = new BemhtmlEngine(); + + if (config.Debug) + { + Environment.SetEnvironmentVariable("EDGE_NODE_PARAMS", "--debug"); + } } public BemhtmlEngine() diff --git a/System.Web.Bem/Engine/BemhtmlTemplate.cs b/System.Web.Bem/Engine/BemhtmlTemplate.cs index 7da3b20..f059392 100644 --- a/System.Web.Bem/Engine/BemhtmlTemplate.cs +++ b/System.Web.Bem/Engine/BemhtmlTemplate.cs @@ -12,7 +12,12 @@ public class BemhtmlTemplate public BemhtmlTemplate(string bundle) { - func = Edge.Func(bundle + ";return function (data, cb) { cb(null, exports.BEMHTML.apply(data));}"); + func = Edge.Func(bundle + @" + ;return function (data, cb) { + cb(null, exports.BEMHTML.apply(data)); + debugger; + } + "); } public Task Apply(object data) diff --git a/WebApplication/Web.config b/WebApplication/Web.config index 7a85dc4..0a043ff 100644 --- a/WebApplication/Web.config +++ b/WebApplication/Web.config @@ -7,7 +7,7 @@
- + diff --git a/WebApplication/WebApplication.csproj b/WebApplication/WebApplication.csproj index b68f5fc..b31284c 100644 --- a/WebApplication/WebApplication.csproj +++ b/WebApplication/WebApplication.csproj @@ -33,6 +33,7 @@ DEBUG;TRACE prompt 4 + true pdbonly @@ -102,6 +103,7 @@ + @@ -1074,7 +1076,7 @@ True 8441 / - http://localhost:8441/ + http://localhost:8081/ False False diff --git a/Windows 8.1 2016-07-04 17-17-09.png b/Windows 8.1 2016-07-04 17-17-09.png new file mode 100644 index 0000000..2188161 Binary files /dev/null and b/Windows 8.1 2016-07-04 17-17-09.png differ