Code Monkey home page Code Monkey logo

sharpkit's Introduction

SharpKit

C# to JavaScript Compiler

This repository contains the complete, fully functional source code for SharpKit cross-compiler.

Library definitions, JsClr framework and other useful libraries is at: https://github.com/SharpKit/SharpKit-SDK

Contributing

Maybe you see there are less commits recently. But you can belive us, sharpkit is still activly used in lots of projects. If you want to contribute, feel free to send us a patch of request a project membership.

Most important Task: Every help in replacing NRefactory with Roslyn is very welcome.

Documentation

Link: https://sharpkit.github.io/

Building

An installer is available here: https://github.com/SharpKit/SharpKit/releases, to build from source code follow this:

Windows
git clone https://github.com/SharpKit/SharpKit.git
cd SharpKit
configure
make

This will build a debug version, to build a release version, please use:

make release
Linux
git clone https://github.com/SharpKit/SharpKit.git
cd SharpKit
chmod +x configure
./configure
make
Creating the installer (without publishing a new version)

Verify the VERSION-file in the root directory . Change the Version number if needed. Than:

configure # When you called this already, you do not need to call it again.
cd contrib/installer/
create

The installer will be created in the contrib directory and can be used for windows and linux. Note: If you create the installer on linux, it cannot be used for windows (because some windows-only libaries are missing). You should generate it on windows for better compatibility.

Changes from previous versions

Path-changes wiki page contains changes made to the file system installation of SharpKit from previous versions.

sharpkit's People

Contributors

arakis avatar danelkhen avatar hultqvist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharpkit's Issues

Visual Studio 2017

Hello,
The provided installer works perfectly with Visual Studio 2012 & 2015, but unfortunately not with Visual Studio 2017. Does anyone know which files must be copied where ?

MIT

Watch and use of people too little, it is better to change the open source protocol to MIT

Abstract properties are being identified as automatic properties

[JsType(JsMode.Prototype, AutomaticPropertiesAsFields = false)]
public abstract class ValueSet
{
    //[JsProperty(NativeField = false)]
    public abstract JsNumber FieldIndicator { get; set; }

}

[JsType(JsMode.Prototype)]
public class FreeValueSet : ValueSet
{
    public FreeValueSet(JsNumber x)
    {
        X = x;
    }

    JsNumber X;

    public override JsNumber FieldIndicator
    {
        get { return X; }
        set { X = value; }
    }
}

[JsType(JsMode.Prototype)]
public class Class1
{
    public static void Main(String[] args)
    {
        ValueSet vs = new FreeValueSet(2);
        HtmlContext.console.info(vs.FieldIndicator);
    }
}

Porting SharpKit to .NET Core

I'm currently porting SharpKit to .NET Core.

Required tasks:

  • Porting SKC dependencies
  • Porting SKC
  • Porting Skc.Tasks library
  • Porting targets files
  • Porting SDK.Defs
  • Porting SDK.FrameWorks
  • Validate js output with old version.
  • Final testing

i / 2 - 1

int i = 3;
int j = i / 2 - 1;

In C#, the value of j is 0.
In SharpKit 5.4.4, the value of j is -1.

The sequence contains more than one element

Hi all,

I'm getting the following error in a project I haven't built with SharpKit in a while. The last time this worked, I was using a commercial version of SharpKit 5. Now I'm using 5.5, installed with the installer downloaded from GitHub, on VS2017 (in order to get VS2017 to work with this, I had to employ the trick described in issue #23).

error SK0000: The sequence contains more than one element [(file path redacted)] 1> ICSharpCode.NRefactory.CSharp.CompilerException: The sequence contains more than one element ---> System.InvalidOperationException: The sequence contains more than one element 1> in System.Linq.Enumerable.Single[TSource](IEnumerable'1 source) 1> in SharpKit.Compiler.CsToJs.ResolveResultConverter.VisitArrayCreateResolveResult(ArrayCreateResolveResult res) 1> in ICSharpCode.NRefactory.Semantics.ArrayCreateResolveResult.AcceptVisitor[R](IResolveResultVisitor'1 visitor) in C:\Users\Dan-el\github\SharpKit\external\NRefactory\ICSharpCode.NRefactory\NRefactory.cs:riga 72 1> in SharpKit.Compiler.CsToJs.ResolveResultConverter.Visit(ResolveResult res) 1> --- Fine della traccia dello stack dell'eccezione interna --- 1> in SharpKit.Compiler.CsToJs.MemberConverter.Visit(IEntity node) 1> in SharpKit.Compiler.CsToJs.TypeConverter.ConvertTypeDefinition(ITypeDefinition ce) 1> in SharpKit.Compiler.CsToJs.TypeConverter.ConvertTypeDefinition(ITypeDefinition ce, JsFile jsFile) 1> in System.Collections.Generic.List1.ForEach(Action1 action) 1> in System.Linq.Extensions.ForEach[T](IEnumerable1 items, Action1 action) in C:\Users\Dan-el\github\SharpKit\external\corex\src\corex\Extensions\System.Linq.cs:riga 85 1> in SharpKit.Compiler.CsToJs.TypeConverter.Process() 1> in SharpKit.Compiler.CompilerTool.ConvertCsToJs() 1> in SharpKit.Compiler.CompilerTool.Time(Action action) 1> in SharpKit.Compiler.CompilerTool.InternalRun()

Unfortunately, the project is very large, and making a decent repro is going to be time-consuming. While I work on that, anyone has any idea on what this means?

struct initialization

Structs are not initialized. Es.:

public struct Point { public int x; public int y; }
void main()
{
Point p;
Console.Out.WriteLine(p.x+" "+p.y};
}

will output "0 0" in C#, but throw an exception in JS because p is undefined.

Problem loading plugin in same solution

Hi,

I've developed a SharpKit plugin for adding AngularJS's DI annotation to our outputed JavaScript classes. It works wonderfully using the SharpKit service and copying the plugin's dll into SharpKit's install directory.

The problem is with the nuget version of SharpKit. I have a sln with 3 projects :

  • Angular interfaces definitions
  • the skc plugin
  • our web application itself

The first two csproj run without any issues but for the last, skc can't find the plugin's dll.
The culprit seems to be CompilerTool.cs#L422 which can't find the plugin if it's not in the same directory as skc.

We're still evaluating SharpKit for our project and having the possibility to seamlessly restoring nuget packages and compile the sln would be a big advantage.

Would it makes sense to add a parameter to to specify the dll path ?
If yes, I could work on a pull request.

enums in inner classes are not generated

If I put this through SharpKit:

public static class Test
{
    internal enum TestEnum
    {
        C = 0, D = 1
    }
    private class TestInner
    {
        internal enum TestInnerEnum
        {
            A = 0, B = 1
        }
    }

    public static void RunTest()
    {
        Console.Write(TestInner.TestInnerEnum.A);
    }
}

TestInnerEnum is not defined anywhere (but TestEnum is).

Problems while porting SharpKit.CSharp.Tasks to .net core 3.1

Here i try to explain, what my problem is.

https://github.com/SharpKit/SharpKit/blob/72f8af8bfbf0052aa28c90cb88bc31faf62da06b/Compiler/CSharp.Tasks/Skc.cs#22
You inherit class Skc from ManagedCompiler.

ManagedCompiler is defined in Assembly "Microsoft.Build.Tasks.v4.0", which is shipped with .net Framework (v4.x).
It's not shipped with .net core anymore and the old assembly is not compatible with .net core.

I need to checkout how i can ght the Skc class get working.

What i found out so far:

https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs
contains exact the needed class. How to compile it, or how to get a nuget package that's containing this class? The class is declared as public.
So, i checked their csproj and found it compiled into "Microsoft.CodeAnalysis.Build.Tasks", thats only published on myget. You can install it via:

dotnet add package Microsoft.CodeAnalysis.Build.Tasks --version 3.8.0-1.20330.5 --source https://dotnet.myget.org/F/roslyn/api/v3/index.json

But now, things going more strange:

CS0534	'Skc' does not implement inherited abstract member 'ManagedCompiler.LogMessages(string, MessageImportance)'

But there's no such method to override! Even with manual writing or with auto implement abstract class feature from VS (it works, it will write the method, but the compiler still complains that there's no such method for overriding).
If you check the sources, you see, that there's really no such method for overriding. Maybe version problems?

A complety other way:

The closest what i found "official" is https://docs.microsoft.com/de-de/dotnet/api/microsoft.build.utilities.tooltask?view=msbuild-16-netcore
but there are some required members missing, like "References", DefineConstants, OutputAssembly, ResponseFiles.

here's the branch i'm working with:
https://github.com/SharpKit/SharpKit/tree/migrate-task

out keyword with array cells

The out keyword does not work properly when applied to an array cell. Example:

    private static void func(out double t)
    {
        t = 1.0;
    }

    public static void RunTest()
    {
        double[] d = new double[1];
        func(out d[0]);
        Console.Write(d[0]);
    }

The above code outputs 1 in C#, but it outputs 0 in SharpKit.

.NET Core support?

Trying to develop a SharpJS test thing using .net core, yet when I do 'dotnet restore', I get this:

mitchell@ubuntu:~/code/thing$ dotnet restore
log  : Restoring packages for /home/mitchell/code/thing/project.json...
log  : Installing SharpJS 1.6.3.
error: Package SharpJS 1.6.3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package SharpJS 1.6.3 supports: net (.NETFramework,Version=v0.0)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.
log  : Writing lock file to disk. Path: /home/mitchell/code/thing/project.lock.json
log  : /home/mitchell/code/thing/project.json
log  : Restore failed in 10808ms.

Errors in /home/mitchell/code/thing/project.json
    Package SharpJS 1.6.3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package SharpJS 1.6.3 supports: net (.NETFramework,Version=v0.0)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.

Here's my project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "copyToOutput": { "includeFiles": ["html"] }
  },
  "dependencies": {
    "SharpJS": "1.6.3"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": "dnxcore50"
    }
  }
}

I can fix this easily by changing the "imports" line to this:
"imports": ["dnxcore50",".NETFramework,v0.0"]
showing that SharpJS does allow projects to be built using .NET Core, just that 'dnxcore50' is not marked as a supported framework.

Compilation time

Hi.

Great framework, but I have a question regarding compile time.
I have a small test project in which I'm testing the framework and the build time for SharpKit is 8 - 10 seconds. This would be very annoying in a real dev cycle when you build you project a number of times per day.
Anything I can do to decrease the compile time?

First time compilation causes hangs in parallel mode

I’ve an issue which occurs quite often on first-time compilation:
SKC hangs when it compiles. I’ve to kill the process and restart the build. Then it works like expected.
This occurs on our large project as well as on a very small test-project.

Here’s an excerpt of the stack when i pause the runtime:

Would be nice if this would be fixed some time. It’s a little annoying to kill skc and restart it over J

image

C# string interpolation causes SKC5 compiler error

Hi,

I'm maintaining a project that uses SharpKit (5.5.0) and I think I've found a bug in SKC, but I'm not the original developer and am not 100% clear on the SharpKit pipeline. I'd like to know if this is a SharpKit bug, a configuration issue in my project, or if I'm just doing something fundamentally wrong.

I have a web project that contains both legacy pages using WebForms, and newer pages using WebAPI+SharpKit. The project compiles in Visual Studio, but the build ultimately fails with Unexpected character $'`.

I've traced the problem to a codebehind file for a legacy WebForms page - a logging statement was refactored to use string interpolation instead of String.Format(). The solution builds successfully if I revert that line.

I'm assuming that the issue is the SharpKit compiler isn't aware of the C# 6 string interpolation syntax, so when the compiler parses the project, it trips over this syntax (even though the problem code is not in a file that SharpKit needs to compile).

Does that make sense? If so, are there any options for a workaround? If not, can you suggest where I might look to diagnose this issue?

Thanks!

Please support Reflection?

current version 5.4.9 seem not support Reflection,will you support that next update?

here is my test code.

using System.Text;
using System.Web.Services.Discovery;
using SharpKit.JavaScript;
using SharpKit.Html;
using SharpKit.jQuery;

namespace SharpKitWebApp1
{
[JsType(JsMode.Global, Filename = "res/Default.js")]
public class DefaultClient
{
private static void DefaultClient_Load()
{
new jQuery(HtmlContext.document.body).append("Ready
");
}

    private static void btnTest_click(DOMEvent e)
    {
        var m = new MyClass();


        var mType = m.GetType(); //.GetFields();


        var fileds = mType.GetFields();

        new jQuery(HtmlContext.document.body).append("<br/>" + fileds);
    }
}

}

[JsType(JsMode.Clr, Filename = "res/MyClass.js")]
public class MyClass
{
public int test = 1;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.