Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion BemtestNet.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
16 changes: 6 additions & 10 deletions Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion ConsoleApplication/Bemhtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
20 changes: 20 additions & 0 deletions ConsoleApplication/ConsoleApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="EdgeJs, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Edge.js.5.9.1\lib\EdgeJs.dll</HintPath>
Expand Down
1 change: 1 addition & 0 deletions ConsoleApplication/templates.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ')';
Expand Down
28 changes: 28 additions & 0 deletions DEBUG.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions System.Web.Bem/Configuration/BemConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
5 changes: 5 additions & 0 deletions System.Web.Bem/Engine/BemhtmlEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ static BemhtmlEngine()
{
config = BemConfiguration.Load();
Instance = new BemhtmlEngine();

if (config.Debug)
{
Environment.SetEnvironmentVariable("EDGE_NODE_PARAMS", "--debug");
}
}

public BemhtmlEngine()
Expand Down
7 changes: 6 additions & 1 deletion System.Web.Bem/Engine/BemhtmlTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<object> Apply(object data)
Expand Down
2 changes: 1 addition & 1 deletion WebApplication/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<configSections>
<section name="bemSettings" type="System.Web.Bem.Configuration.BemConfiguration"/>
</configSections>
<bemSettings Mapper="Single" />
<bemSettings Mapper="Single" Debug="true" />
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
Expand Down
4 changes: 3 additions & 1 deletion WebApplication/WebApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -102,6 +103,7 @@
<Content Include="Bem\desktop.blocks\p-index\p-index.bemhtml.js" />
<Content Include="Bem\desktop.blocks\p-index\p-index.deps.js" />
<Content Include="Bem\desktop.bundles\default\default.bemdecl.js" />
<Content Include="Bem\desktop.bundles\default\default.bemhtml.js" />
<Content Include="Bem\desktop.bundles\index\index.bemdecl.js" />
<Content Include="Bem\libs\bem-components\common.blocks\attach\attach.bemhtml.js" />
<Content Include="Bem\libs\bem-components\common.blocks\attach\attach.bh.js" />
Expand Down Expand Up @@ -1074,7 +1076,7 @@
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>8441</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:8441/</IISUrl>
<IISUrl>http://localhost:8081/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
Expand Down
Binary file added Windows 8.1 2016-07-04 17-17-09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.