Code Monkey home page Code Monkey logo

mcs-icodecompiler's People

Contributors

aeroson avatar jakubnei 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

mcs-icodecompiler's Issues

error occur when using "dynamic" and "enum"

When I used the "dynamic" and "enum" as follow:
class DynamicEnum
{
enum TEST
{
t1
}

    TEST _test;

    void Selected(dynamic param)
    {
        _test = param;
    }
}

I got an error without useful info:
error : 10(18,14): native.DynamicEnum.Selected(dynamic)
UnityEngine.Debug:Log(Object)
CSharpCompiler.UnityLogTextWriter:Log(String) (at Assets/ThridParty/mcs_ICodeCompiler/UnityLogTextWriter.cs:19)
CSharpCompiler.SourceCodeBundle:.ctor(ScriptBundleLoader, IEnumerable1) (at Assets/ThridParty/mcs_ICodeCompiler/ScriptBundleLoader.cs:227) CSharpCompiler.ScriptBundleLoader:LoadAndWatchSourceBundle(IEnumerable1) (at Assets/ThridParty/mcs_ICodeCompiler/ScriptBundleLoader.cs:41)

But if change the type of _test as "string", the error is disappeared

Compiling using CodeCompiler.CompileAssemblyFromSourceBatch() results in an exception

Error (101): The namespace global::' already contains a definition forTest'

Where Test is the name of one of the classes to be compiled (and no it's not already in the project).

It doesn't throw an error if you compile only 1 source string at a time, and CompileAssemblyFromFileBatch() works fine with any number of files.

The best I've been able to determine what is happening is in CompileAssemblyFromSourceBatch(), the subsequent:

Func<Stream> getStream = () => { return new MemoryStream(Encoding.UTF8.GetBytes(source ?? "")); };

overwrite the previous MemoryStreams that are stored in source files, so all the source files end up with the same code.

Building On Unity 2017

Assets/CSharpCompiler/CodeCompiler.cs(17,33): error CS0246: The type or namespace name `ICodeCompiler' could not be found. Are you missing an assembly reference?

The same for CompilerResults and CompilerParameters, both cannot be found.

Disable updating files

Hi,

Is it possible to not use Synchronized Invoke and instead just compile the files once at startup?

Non-MonoBehaviour Scripts

At the moment it seems that only scripts inheriting MonoBehaviour will work successfully, otherwise the constructor will have to be empty. If a script does not inherit MonoBehaviour but has a non-empty constructor then the following error will be thrown in the Unity Console:

The class being tested here is called "Test"

MissingMethodException: Method not found: 'Default constructor not found...ctor() of RuntimeCSharpCompiler.Test'.

This has something to do with this where System.Activator.CreateInstance does not know what to do when trying to instantiate a class that requires arguments in the constructor.

Do you have any ideas for how to work around this limitation? Currently I am looking into the docs for CreateInstance so I should figure something out soon but was just wondering if you had any thoughts on this.

Thanks!

Compiling mcs

Hi,

I'd like to compile mcs myself and was wondering if you could add some more details as to how you compiled it. Such as what was removed from the Mono SDK and then what externals were added.

Thank you 😄

Conflict with new Visual studio

below are two errors I'm getting constantly now (after recent update of the unity[2017.3] and visual studio [15.5] for this library, otherwise this is amazing code! )

The imported type `Mono.CSharp.Target' is defined multiple times

Cannot implicitly convert type Mono.CSharp.Target [SyntaxTree.VisualStudio.Unity.Bridge, Version=3.5.0.2, Culture=neutral, PublicKeyToken=null -- C:\Program Files (x86)\Microsoft Visual Studio Tools for Unity\15.0\Editor\SyntaxTree.VisualStudio.Unity.Bridge.dll]' to Mono.CSharp.Target [mcs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -- C:\Projects\Game\Assets\Plugins\MCSCompiler\mcs.dll]'. An explicit conversion exists (are you missing a cast?)

[NOT AN ISSUE] Thank you for creating this!

I just had to change 3 lines from my code, to make it work with mcs-ICodeCompiler, and now i can build my game for windows with...

¡¡MODS SUPPORT!!

Thank you for spending your time to make this and for sharing it for free!
If i ever finish my game, i will send you a key!

Support Android platform?

I tried it on the Android platform, but it didn't seem to work. I don't know if my usage is wrong. Has anyone been successful?

thank :)

Unhandled Exception: System.Reflection.ReflectionTypeLoadException

I get this error after adding your project to unity. I am using Unity 5, which may be the issue. Here's the full error:

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 

Multiple files

Hi,

Can you please provide an example for how I can load multiple files? When adding a second file the GUI shows two buttons, loading one script works perfectly, but I get an error whenever I try to load a second script.

Any help is greatly appreciated

NotSupportedException: The invoked member is not supported in a dynamic module.
System.Reflection.Emit.AssemblyBuilder.get_Location () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:241)
CSharpCompiler.ScriptBundleLoader+ScriptBundle.<ScriptBundle>m__6 (System.Reflection.Assembly a) (at Assets/CSharpCompiler/ScriptBundleLoader.cs:57)
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[System.Reflection.Assembly,System.String].MoveNext ()
System.Collections.Generic.List`1[System.String].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[System.String]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
System.Linq.Enumerable.ToArray[String] (IEnumerable`1 source)
CSharpCompiler.ScriptBundleLoader+ScriptBundle..ctor (CSharpCompiler.ScriptBundleLoader manager, IEnumerable`1 filePaths) (at Assets/CSharpCompiler/ScriptBundleLoader.cs:57)
CSharpCompiler.ScriptBundleLoader.LoadAndWatchScriptsBundle (IEnumerable`1 fileSources) (at Assets/CSharpCompiler/ScriptBundleLoader.cs:33)
CSharpCompiler.DemoLoadScripts.OnGUI () (at Assets/CSharpCompiler/Demo/DemoLoadScripts.cs:61)

Error "assemblyString cannot have zero length" + fix

(firstly, great resource, thanks!)

Just fixed a tiny bug in ScriptBundleLoader that caused the titular bug.
Line 59 (middle of the LINQ in ScriptBundle constructor), switch:
.Where(a => !(a is System.Reflection.Emit.AssemblyBuilder))
to
.Where(a => (!(a is System.Reflection.Emit.AssemblyBuilder) && !string.IsNullOrEmpty(a.Location)))
to remove blanks.
HTH

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.