Skip to content
Browse files

DotWeb.Debugger up and running, replaces old hosted mode that ran ins…

…ide of asp.net.
  • Loading branch information...
1 parent 5f3abea commit fd6326cec791a88eedf16a2b2a42991b8763bd03 @flaub committed Jun 26, 2010
View
2 DotWeb.Installer/Product.wxs
@@ -130,7 +130,7 @@
<!--https://developer.mozilla.org/En/Plugins/The_First_Install_Problem-->
<ComponentGroup Id="Plugin.npapi">
<Component Id="NPDotWeb.dll" Guid="*" Directory="INSTALLDIR">
- <File Id="NPDotWeb.dll" KeyPath="yes" Source="$(var.SolutionDir)plugins\npapi\bin\$(var.Configuration)\NPDotWeb.dll"/>
+ <File Id="NPDotWeb.dll" KeyPath="yes" Source="$(var.SolutionDir)build\bin\$(var.Configuration)\NPDotWeb.dll"/>
<RegistryKey Root="HKLM" Key="Software\MozillaPlugins\@bluetreelabs.com/DotWeb,version=0.0.1" Action="create">
<RegistryValue Name="Path" Value="[#NPDotWeb.dll]" Type="string"/>
<RegistryValue Name="ProductName" Value="DotWeb Development-Mode Plugin" Type="string"/>
View
15 DotWeb.sln
@@ -78,6 +78,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotWeb.System", "src\DotWeb
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotWebAttributes", "src\DotWebCoreLib\DotWebAttributes.csproj", "{F02F94A5-422E-4585-BB7B-160A8C6B488F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotWeb.Debugger", "src\DotWeb.Debugger\DotWeb.Debugger.csproj", "{0182B988-A1F6-4D02-9B99-D8B7706952C8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -377,6 +379,18 @@ Global
{F02F94A5-422E-4585-BB7B-160A8C6B488F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F02F94A5-422E-4585-BB7B-160A8C6B488F}.Release|Win32.ActiveCfg = Release|Any CPU
{F02F94A5-422E-4585-BB7B-160A8C6B488F}.Release|x86.ActiveCfg = Release|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Release|Win32.ActiveCfg = Release|Any CPU
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -392,6 +406,7 @@ Global
{DE8A6C27-B315-41E3-82BF-7A3741C7653D} = {5371A387-4AAD-472B-B6F8-3A85C553790E}
{63D7BDD6-78BE-46B8-9BD3-E2026E34F4CB} = {5371A387-4AAD-472B-B6F8-3A85C553790E}
{F02F94A5-422E-4585-BB7B-160A8C6B488F} = {5371A387-4AAD-472B-B6F8-3A85C553790E}
+ {0182B988-A1F6-4D02-9B99-D8B7706952C8} = {5371A387-4AAD-472B-B6F8-3A85C553790E}
{0A46B99F-8A61-4544-8B1D-E5117DABBD90} = {68BADD68-6C2C-4D04-BCD9-84E851FF97C1}
{45AD857D-00EA-44CF-A3D4-8355DDFE1623} = {68BADD68-6C2C-4D04-BCD9-84E851FF97C1}
{E3610104-B2F5-4C28-BB26-6719001B43FA} = {68BADD68-6C2C-4D04-BCD9-84E851FF97C1}
View
8 plugins/npapi/Debug.cpp
@@ -27,10 +27,14 @@ void Debug::print(const char* fmt, ...) {
}
void Debug::println(const char* fmt, ...) {
+ char fmtln[1024];
char buf[1024];
+
+ strcpy_s(fmtln, fmt);
+ strcat_s(fmtln, "\n");
+
va_list args;
va_start(args, fmt);
- vsprintf_s(buf, 1024, fmt, args);
+ vsprintf_s(buf, fmtln, args);
OutputDebugStringA(buf);
- OutputDebugStringA("\n");
}
View
15 plugins/npapi/JsAgent.cpp
@@ -77,6 +77,12 @@ JsAgent::~JsAgent() {
void JsAgent::onDestroy() {
Debug::println("JsAgent::onDestroy");
+
+ QuitMessage msg;
+ ArchiveWriter<Channel> writer(*m_channel);
+ if(!Message::send(msg, writer)) {
+ Debug::println("JsAgent::onDestroy> could not send quit msg");
+ }
}
bool JsAgent::enumeration(NPIdentifier** values, uint32_t* count) {
@@ -139,13 +145,15 @@ bool JsAgent::onLoad(const NPVariant* args, unsigned argCount) {
Debug::println("JsAgent::onLoad");
if(argCount != 4) {
+ Debug::println("JsAgent::onLoad> argCount != 4");
return false;
}
if( !NPVARIANT_IS_OBJECT(args[0]) ||
!NPVARIANT_IS_STRING(args[1]) ||
!NPVARIANT_IS_INT32(args[2]) ||
!NPVARIANT_IS_STRING(args[3]) ) {
+ Debug::println("JsAgent::onLoad> arg types wrong");
return false;
}
@@ -158,6 +166,7 @@ bool JsAgent::onLoad(const NPVariant* args, unsigned argCount) {
var.set(pDebug);
if(!NPN_SetProperty(getNPP(), m_window, methods.debug, var.ptr())) {
+ Debug::println("JsAgent::onLoad> set property failed");
return false;
}
@@ -170,15 +179,18 @@ bool JsAgent::onLoad(const NPVariant* args, unsigned argCount) {
std::string typeName(npstr.UTF8Characters, npstr.UTF8Length);
if(!m_channel->connect(host.c_str(), port)) {
+ Debug::println("JsAgent::onLoad> could not connect");
return false;
}
LoadMessage msg;
msg.typeName = typeName;
ArchiveWriter<Channel> ar(*m_channel);
- if(!Message::send(msg, ar))
+ if(!Message::send(msg, ar)) {
+ Debug::println("JsAgent::onLoad> send failed");
return false;
+ }
JsValue ret;
return dispatchAndReturn(ret);
@@ -233,6 +245,7 @@ bool JsAgent::dispatchAndReturn(JsValue& ret) {
}
bool JsAgent::onUnload() {
+ Debug::println("JsAgent::onUnload");
m_channel->disconnect();
return false;
}
View
2 plugins/npapi/NPDotWeb.vcproj
@@ -17,7 +17,7 @@
<Configurations>
<Configuration
Name="Debug|Win32"
- OutputDirectory="bin\$(ConfigurationName)"
+ OutputDirectory="$(SolutionDir)build\bin\$(ConfigurationName)"
IntermediateDirectory="bin\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
View
69 src/DotWeb.Debugger/DotWeb.Debugger.csproj
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{0182B988-A1F6-4D02-9B99-D8B7706952C8}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DotWeb.Debugger</RootNamespace>
+ <AssemblyName>DotWeb.Debugger</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\build\bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\DotWeb.Hosting.Bridge\DotWeb.Hosting.Bridge.csproj">
+ <Project>{CDB3DD8E-7178-42A5-BA0E-F0FABC627B46}</Project>
+ <Name>DotWeb.Hosting.Bridge</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\DotWeb.Hosting.Weaver\DotWeb.Hosting.Weaver.csproj">
+ <Project>{DE8A6C27-B315-41E3-82BF-7A3741C7653D}</Project>
+ <Name>DotWeb.Hosting.Weaver</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\DotWeb.Hosting\DotWeb.Hosting.csproj">
+ <Project>{9004E34C-2D35-40EE-BE98-C1AED18081CF}</Project>
+ <Name>DotWeb.Hosting</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\DotWeb.Utility\DotWeb.Utility.csproj">
+ <Project>{F303A189-1B53-4FF6-B6AC-8972444A6B7B}</Project>
+ <Name>DotWeb.Utility</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
70 src/DotWeb.Debugger/Program.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Net.Sockets;
+using System.Net;
+using DotWeb.Hosting;
+using DotWeb.Hosting.Bridge;
+using System.Diagnostics;
+using System.Threading;
+
+namespace DotWeb.Debugger
+{
+ class Program
+ {
+ static void Main(string[] args) {
+ new Program().Start();
+ }
+
+ public void Start() {
+ var listener = new TcpListener(IPAddress.Loopback, 0x1337);
+ listener.Start();
+ while (true) {
+ var client = listener.AcceptTcpClient();
+ ThreadPool.QueueUserWorkItem((state) => RunInAppDomain(client));
+ }
+ }
+
+ private void RunInAppDomain(TcpClient client) {
+ var curDomain = AppDomain.CurrentDomain;
+ var setup = curDomain.SetupInformation;
+
+ var appDomain = AppDomain.CreateDomain("DotWeb Hosting Environment", null, setup);
+ var type = typeof(IsolatedContext);
+ var context = (IsolatedContext)appDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);
+
+ try {
+ context.Run(client.GetStream());
+ }
+ finally {
+ client.Close();
+ AppDomain.Unload(appDomain);
+ }
+ }
+
+ /// <summary>
+ /// This allows static variables to be reset on each new request.
+ /// It also serves as a good way to isolate each request from each other.
+ /// </summary>
+ class IsolatedContext : MarshalByRefObject
+ {
+ public void Run(NetworkStream stream) {
+ HostedMode.Host = new CallContextStorage();
+ try {
+ var session = new RemoteSession(stream, stream);
+ var factory = new DefaultFactory();
+ var bridge = new JsBridge(session, factory);
+ HostedMode.Host = bridge;
+ bridge.DispatchForever();
+ }
+ catch (Exception ex) {
+ Debug.WriteLine(ex);
+ }
+ finally {
+ stream.Close();
+ }
+ }
+ }
+ }
+}
View
36 src/DotWeb.Debugger/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DotWeb.Debugger")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("DotWeb.Debugger")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("d2933f7d-8ea3-4f3a-bdd2-8464c663db80")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
3 src/DotWeb.Hosting.Bridge/HostingServer.cs
@@ -22,6 +22,7 @@
using System;
using System.Diagnostics;
using DotWeb.Hosting.Weaver;
+using System.Threading;
namespace DotWeb.Hosting.Bridge
{
@@ -70,8 +71,6 @@ class HostingServer : IHostingServer
}
public void Start() {
- this.listener.Start();
- this.listener.BeginAcceptTcpClient(OnAccept, listener);
}
private void OnAccept(IAsyncResult ar) {
View
51 src/DotWeb.Hosting.Bridge/JsBridge.cs
@@ -20,6 +20,7 @@
using System.Linq;
using System.Reflection;
using System.Diagnostics;
+using DotWeb.Utility;
namespace DotWeb.Hosting.Bridge
{
@@ -30,6 +31,8 @@ namespace DotWeb.Hosting.Bridge
using ReferenceToObjectMap = Dictionary<int, object>;
using JsObjectToReferenceMap = Dictionary<object, int>;
+ using System.IO;
+ using DotWeb.Hosting.Weaver;
public class JsBridge : IDotWebHost
{
@@ -131,17 +134,35 @@ public class JsBridge : IDotWebHost
return true;
}
+ private void Reset() {
+ this.remoteDelegates.Clear();
+ this.functionCache.Clear();
+ this.objToRef.Clear();
+ this.refToObj.Clear();
+ this.jsObjectToRef.Clear();
+ this.isUnwrapping = false;
+ }
+
+ private Type PrepareType(string typeSpec) {
+ var parts = typeSpec.Split(',');
+ var typeName = parts[0].Trim();
+ var asmName = parts[1].Trim();
+ var binPath = parts[2].Trim();
+ var weaver = new SimpleWeaver(binPath, binPath, new string[] { binPath }, false);
+
+ var asmPath = Path.Combine(binPath, asmName);
+ if (!asmPath.EndsWith(".dll")) {
+ asmPath += ".dll";
+ }
+ var asm = weaver.ProcessAssembly(asmPath);
+ return asm.GetType(typeName);
+ }
+
private void OnLoad(LoadMessage msg) {
try {
- this.remoteDelegates.Clear();
- this.functionCache.Clear();
- this.objToRef.Clear();
- this.refToObj.Clear();
- this.jsObjectToRef.Clear();
- this.isUnwrapping = false;
+ Reset();
- Type type = Type.GetType(msg.TypeName);
- CreateInstance(type);
+ CreateInstance(PrepareType(msg.TypeName));
var value = new JsValue(JsValueType.Void, null);
var retMsg = new ReturnMessage { Value = value };
@@ -278,11 +299,19 @@ public class JsBridge : IDotWebHost
return ret;
}
+ private static bool IsJsObject(Type type) {
+ return type.IsDefinedInHierarchy<JsObjectAttribute>();
+ }
+
+ private static bool IsJsDynamic(Type type) {
+ return type.IsDefinedInHierarchy<JsDynamicAttribute>();
+ }
+
private JsValue WrapValue(object arg, bool isVoid) {
if (isVoid)
return new JsValue(JsValueType.Void, null);
- if (arg.GetType().IsDefined(typeof(JsObjectAttribute), true)) {
+ if (IsJsObject(arg.GetType())) {
int handle = GetRemoteReference(arg);
Debug.Assert(handle != 0);
return new JsValue(JsValueType.JsObject, handle);
@@ -330,7 +359,7 @@ public class JsBridge : IDotWebHost
int id;
if (!GetLocalReference(arg, out id)) {
IJsWrapper wrapper;
- if (arg.GetType().IsDefined(typeof(JsDynamicAttribute), true)) {
+ if (IsJsDynamic(arg.GetType())) {
wrapper = GetDynamicWrapper(arg);
}
else {
@@ -400,7 +429,7 @@ public class JsBridge : IDotWebHost
public object Invoke(object scope, object objMethod, object[] args) {
try {
MethodBase method = (MethodBase)objMethod;
- if (method.DeclaringType.IsDefined(typeof(JsDynamicAttribute), true)) {
+ if (IsJsDynamic(method.DeclaringType)) {
return InvokeOnDynamic(scope, (MethodInfo)method, args);
}
View
3 src/DotWeb.Hosting.Weaver/SimpleWeaver.cs
@@ -9,6 +9,7 @@
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
+using System.Runtime.CompilerServices;
namespace DotWeb.Hosting.Weaver
{
@@ -273,6 +274,7 @@ static class PredefinedTypes
public static readonly Type JsIntrinsic = typeof(JsIntrinsicAttribute);
public static readonly Type JsObject = typeof(JsObjectAttribute);
public static readonly Type JsDynamic = typeof(JsDynamicAttribute);
+ public static readonly Type Extension = typeof(ExtensionAttribute);
public static readonly List<SR.ConstructorInfo> JsAttributes = new List<SR.ConstructorInfo>();
@@ -293,6 +295,7 @@ static class PredefinedTypes
PrepareJsAttribute(JsIntrinsic);
PrepareJsAttribute(JsObject);
PrepareJsAttribute(JsDynamic);
+ PrepareJsAttribute(Extension);
}
private static void PrepareJsAttribute(Type type) {
View
3 src/DotWeb.System/DotWeb.System.csproj
@@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Compile Include="..\..\CommonAssemblyInfo.cs">
+ <Link>Properties\CommonAssemblyInfo.cs</Link>
+ </Compile>
<Compile Include="Action.cs" />
<Compile Include="Collections\Generic\Dictionary.cs" />
<Compile Include="Collections\Generic\EqualityComparer.cs" />
View
18 src/DotWeb.System/Properties/AssemblyInfo.cs
@@ -7,12 +7,7 @@
// associated with an assembly.
[assembly: AssemblyTitle("DotWeb.System")]
[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("DotWeb.System")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
@@ -21,16 +16,3 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9629151b-a7bf-4be8-8029-436f4fc2e3ed")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
View
44 src/DotWeb.System/StringExtensions.cs
@@ -2,29 +2,29 @@
{
public static class StringExtensions
{
- /// <summary>
- /// Returns a String containing the character at position pos in the String resulting from converting this object to a
- /// String. If there is no character at that position, the result is the empty String. The result is a String value, not a
- /// String object.
- /// </summary>
- /// <param name="str"></param>
- /// <param name="pos"></param>
- /// <returns></returns>
- [JsMacro("{1}.charAt({2})")]
- public static extern string CharAt(this string str, int pos);
+ ///// <summary>
+ ///// Returns a String containing the character at position pos in the String resulting from converting this object to a
+ ///// String. If there is no character at that position, the result is the empty String. The result is a String value, not a
+ ///// String object.
+ ///// </summary>
+ ///// <param name="str"></param>
+ ///// <param name="pos"></param>
+ ///// <returns></returns>
+ //[JsMacro("{1}.charAt({2})")]
+ //public static extern string CharAt(this string str, int pos);
- /// <summary>
- /// Returns a Number (a nonnegative integer less than 216) representing the code unit value of the character at
- /// position pos in the String resulting from converting this object to a String. If there is no character at that
- /// position, the result is NaN.
- /// </summary>
- /// <param name="str"></param>
- /// <param name="pos"></param>
- /// <returns></returns>
- [JsMacro("{1}.charCodeAt({2})")]
- public static extern int CharCodeAt(this string str, int pos);
+ ///// <summary>
+ ///// Returns a Number (a nonnegative integer less than 216) representing the code unit value of the character at
+ ///// position pos in the String resulting from converting this object to a String. If there is no character at that
+ ///// position, the result is NaN.
+ ///// </summary>
+ ///// <param name="str"></param>
+ ///// <param name="pos"></param>
+ ///// <returns></returns>
+ //[JsMacro("{1}.charCodeAt({2})")]
+ //public static extern int CharCodeAt(this string str, int pos);
- [JsMacro("{1}.valueOf({2})")]
- public static extern string ValueOf(this string str);
+ //[JsMacro("{1}.valueOf({2})")]
+ //public static extern string ValueOf(this string str);
}
}
View
1 src/DotWeb.Translator/CodeModelExtensions.cs
@@ -17,7 +17,6 @@
using System;
using System.Linq;
-using DotWeb.Client;
using DotWeb.Decompiler.CodeModel;
using System.Reflection;
using Mono.Cecil;
View
4 src/DotWeb.Translator/DotWeb.Translator.csproj
@@ -71,10 +71,6 @@
<Content Include="Generator\JavaScript\Runtime.js" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\DotWeb.Client\DotWeb.Client.csproj">
- <Project>{0A46B99F-8A61-4544-8B1D-E5117DABBD90}</Project>
- <Name>DotWeb.Client</Name>
- </ProjectReference>
<ProjectReference Include="..\DotWeb.Decompiler\DotWeb.Decompiler.csproj">
<Project>{69561EF0-26F3-4190-89EA-AAE937A5D88F}</Project>
<Name>DotWeb.Decompiler</Name>
View
1 src/DotWeb.Translator/Generator/JavaScript/JsCodeGenerator.cs
@@ -20,7 +20,6 @@
using System.Linq;
using System.IO;
using System.CodeDom.Compiler;
-using DotWeb.Client;
using DotWeb.Translator.Properties;
using DotWeb.Decompiler.CodeModel;
using DotWeb.Decompiler;
View
1 src/DotWeb.Translator/Generator/JavaScript/JsPrinter.cs
@@ -19,7 +19,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using DotWeb.Client;
using DotWeb.Utility;
using System.Diagnostics;
using DotWeb.Decompiler.CodeModel;
View
1 src/DotWeb.Translator/TranslationContext.cs
@@ -20,7 +20,6 @@
using System.Collections.Generic;
using System.Text;
using DotWeb.Translator.Generator.JavaScript;
-using DotWeb.Client;
using DotWeb.Utility;
using DotWeb.Decompiler.CodeModel;
using DotWeb.Decompiler;
View
9 src/DotWeb.Utility/AttributeExtensions.cs
@@ -32,6 +32,15 @@ public static class AttributeExtensions
public static R GetCustomAttribute<R>(this Type type) where R : class {
return type.GetCustomAttributes(typeof(R), false).FirstOrDefault() as R;
}
+
+ public static bool IsDefinedInHierarchy<T>(this Type type) {
+ while (type != null && type != typeof(object)) {
+ if (type.IsDefined(typeof(T), true))
+ return true;
+ type = type.BaseType;
+ }
+ return false;
+ }
}
}
View
12 src/DotWeb.Web/ClientCodeRenderer.cs
@@ -133,14 +133,6 @@ public class ClientCodeRenderer
}
private void RenderHostedMode(HtmlTextWriter writer) {
- var hostingServer = HostingServerFactory.CreateHostingServer();
- hostingServer.Start();
-
- var ip = hostingServer.EndPoint;
- var aqtn = new AssemblyQualifiedTypeName(Source);
- var binPath = context.MapPath("/bin");
- var src = hostingServer.PrepareType(binPath, aqtn);
-
//<embed id="__$plugin" type="application/x-dotweb"/>
writer.AddAttribute(HtmlTextWriterAttribute.Id, "__$plugin");
writer.AddAttribute(HtmlTextWriterAttribute.Type, DotWebMimeType);
@@ -154,7 +146,9 @@ public class ClientCodeRenderer
writer.WriteLine(Resources.JsHelper);
var url = context.RequestUrl;
- string js = string.Format(Resources.HostedEntry, url.Host, ip.Port, src);
+ var binPath = context.MapPath("/bin").Replace("\\", "\\\\");
+ var typeSpec = HttpUtility.HtmlEncode(string.Format("{0}, {1}", Source, binPath));
+ string js = string.Format(Resources.HostedEntry, url.Host, 0x1337, typeSpec);
writer.WriteLine(js);
writer.RenderEndTag();
View
2 src/DotWebCoreLib/DotWebAttributes.csproj
@@ -45,7 +45,7 @@
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="DotWebAttributes.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Properties\DotWebAttributes.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
4 src/DotWebCoreLib/Object.cs
@@ -31,5 +31,9 @@ public class Object
[JsCamelCase]
public extern virtual string ToString();
+
+ public Type GetType() {
+ return null;
+ }
}
}
View
37 src/DotWebCoreLib/Properties/DotWebAttributes.cs
@@ -0,0 +1,37 @@
+// Copyright 2009, Frank Laub
+//
+// This file is part of DotWeb.
+//
+// DotWeb is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// DotWeb is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with DotWeb. If not, see <http://www.gnu.org/licenses/>.
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DotWebAttributes")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyProduct("DotWeb")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("E7630289-57F9-4551-B4AE-1E5A85747026")]
+
View
2 test/DotWeb.Functional.Test/Client/TestResultView.cs
@@ -69,7 +69,7 @@ class TestResultView : JsScript
AddRow(name, expectedException, "<None>", false);
}
catch (Exception ex) {
- var actualException = ex.GetTypeName();
+ var actualException = ex.GetType().Name;
AddRow(name, expectedException, actualException, expectedException == actualException);
}
}
View
8 test/DotWeb.Functional.Test/Server/DotWeb.Functional.Test.Server.csproj
@@ -80,10 +80,6 @@
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\Client\DotWeb.Functional.Test.Client.csproj">
- <Project>{90270A7A-2070-4A94-B6AC-644F52C37B51}</Project>
- <Name>DotWeb.Functional.Test.Client</Name>
- </ProjectReference>
<ProjectReference Include="..\..\..\src\DotWeb.Web.Mvc\DotWeb.Web.Mvc.csproj">
<Project>{0EA77083-0F93-43EA-AB3D-52FE0FEE4599}</Project>
<Name>DotWeb.Web.Mvc</Name>
@@ -92,6 +88,10 @@
<Project>{81320140-BA96-4316-AF77-34CD16952DB0}</Project>
<Name>DotWeb.Web</Name>
</ProjectReference>
+ <ProjectReference Include="..\Client\DotWeb.Functional.Test.Client.csproj">
+ <Project>{90270A7A-2070-4A94-B6AC-644F52C37B51}</Project>
+ <Name>DotWeb.Functional.Test.Client</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="js\" />
View
6 test/DotWeb.Hosting.Test/JsBridgeTest.cs
@@ -23,10 +23,14 @@
using System.Reflection;
using System.IO;
using System.Runtime.Remoting;
-using JsDynamic = /* FIXME */ System.Object;
namespace DotWeb.Hosting.Test
{
+ [JsDynamic]
+ class JsDynamic
+ {
+ }
+
[TestFixture]
public class JsBridgeTest
{

0 comments on commit fd6326c

Please sign in to comment.
Something went wrong with that request. Please try again.