flaub / dotweb Goto Github PK
View Code? Open in Web Editor NEW.NET Web Toolkit - GWT Clone
License: Other
.NET Web Toolkit - GWT Clone
License: Other
I'm still not happy with the current approach
Currently, developers will reference the mscorlib assembly in their own Script assemblies. This is required right now so that Hosted-Mode works properly. However, this prevents the compiler from reporting errors for methods and types that are not supported by the DotWeb.System.
I've experimented with having script developers reference a separate DotWeb.System assembly by using the /nostdlib+ option. Hosted-mode requires real object and reflection services from the dotnetfx. So there is a conflict here. I've tried 2 things to fix this issue:
An entirely different approach would be to have a separate compile step that would be to verify and report errors in case a developer did reference an unsupported type or method. Preferably this check would occur during compile time, but it could also occur only in web-mode when the translator tries to do it's thing.
A compile step would probably mean a custom build task. It would attempt to build the target assembly using /nostdlib+. The output could either be safely ignored, or it could be merged into the target assembly so that the translator could be simplified (removing the need to treat the System.* specially).
If i create a simple delegate like Action and call it:
Action action = ()=>Global.Window.alert("test");
action();
DotWeb generates:
action.Invoke();
Instead of
action();
Error types in javascript need to be wrapped in a way that their interface is .NET-like. This is needed to support catching native javascript errors with .NET catch clauses. These wrapped types should be derived from System.Exception so that a catch(Exception) will properly catch all exceptions.
I'm not sure why this is happening. One possibility is that the server's thread is being aborted because the client might be reloading the plugin on start.
A workaround for now is to simply refresh the page, this causes the plugin to connect successfully.
A possibly solution would be to have the client be resilient to connection failures by trying to reconnect to the server. It also might make sense to have the client connect to a well-known port on the server side, so that the plugin loading can be downloaded and executed ala ajax.
If i create the following class (here a simple wrapper for native jQuery):
namespace jQuery13
{
[JsNamespace]
[JsIntrinsic]
public class jQueryTest : JsObject
{
public extern jQueryTest(Document document);
}
}
and then call it like this:
new jQueryTest(Global.Document);
DotWeb puts the namespace in front of the call in generated Javascript.
new jQuery13.jQueryTest($doc);
Since jQuery have no namespace in front if it, this call dose not work.
Will add a test case for this soon. For now the DotWeb.Translator.Test/TranslationTest/Callback unit test shows that a throw is causing an errant break; to be emitted.
The following simple class will generate a wrong lambda declaration.
public class Class1
{
public void Call(Action action)
{
action();
}
public Class1()
{
Call(() => Global.Window.alert("test"));
}
}
Will generate this:
Web.Script.Class1._.ctor_b__0 = function() {
$wnd.alert("test");
};
Since javascript doesn't have a char native data type, we'll need to emulate it somehow. The closest analog is either an integer or a string with a single element. Neither of these are exactly what a .NET Char type is, and this causes problems when trying to use APIs that take char types.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.