-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Support .NET Core #1142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I did a brief analysis of Antlr4.Runtime compiled against .NET Core. See attached file for all compiler errors. Ambiguous reference
Missing API
ICustomAttributeProvider missing -> use same impl. as PORTABLE There are also some issues around reflection, but it is not a widespread problem. |
I just checked out the repo, created a new .NET Core project for Antlr.Runtime, included the source code, and fixed all compiler errors. Now it properly compiles. The ambiguous reference were resolved, by extending the conditional compilation to include a new define DOTNETCORE. This resolved the problem, because .NET Core already supports ConcurrentDictionary and Tuple. The SerializableAttribute is missing, because .NET Core dropped support for binary serialization. Therefore, the attribute can just be removed (other serialization mechanisms do not depend on the attribute). I haven't, yet, dug into the code too deep, so I don't know if binary serialization is needed. All the missing APIs concerning reflection (including that Type does not implement ICustomAttributeProvider) could be resolved, because those APIs have just been moved to the new type TypeInfo for performance reasons. The TypeInfo for a Type object can be retrieved by calling GetTypeInfo(), which is an extension method for the Type class. There is just one problem left, because now the "old" project ("Antlr.Runtime.vs2013") does not build anymore. I think, that is because Visual Studio confuses the project.json from the other project, and tries to compile it using that. Therefore these two projects should be isolated by moving them into separate folders. I am going to fork the repository and push my changes onto it. I would like you guys to review my changes and give me some feedback (or would you prefer if I created a pull request right away?) |
I have now forked the repository, and pushed my commits. You can view the fork here: https://github.com/lecode-official/antlr4. |
Hi, Envoyé de mon iPhone
|
As MSBuild is coming back to .NET Core, I think point 2 of @natemcmaster 's comment would be soon invalid. In my opinion, a better time to port ANTLR 4 to .NET Core should be some time when Microsoft officially finishes .NET Core/MSBuild integration, not now. Anyway I will also check the PR associated #1229 to see if it meets my project's requirements. |
I opened a new PR #1271 to show another approach to go to .NET Core/.NET Standard. |
Hey, I'm porting a project containing an ANTLR4 grammar from .NET Framework to .NET Core. For the .NET Core version of this project, I've referenced the latest prerelease version (v4.5.3.1-beta001) and it restores this successfully. However, I'm wondering if there's a way yet to do code-gen from the grammar file (i.e. @natemcmaster's second point). Or should I just copy the generated files from the |
we have merged in a dotnet update so closing this. |
It would be great to add support for using Antlr4 with .NET Core projects. There are 2 items here to truly support antlr on .NET Core:
(1) Antlr4 runtime. Ensure that runtime and generated code are compatible with .NET core apps. FWIW it appears the "netcore45" assembly in the nupkg already supports .NET Core. So this may be as simple as updating the packaging to install to the right TFMs.
(2) Antlr4 code-gen. Previously antlr4cs tied into MSBuild. Since .NET Core projects generally won't use MSBuild, it would be nice to add alternate ways of running antlr4 code gen. This could be done as a project tool for dotnet CLI. In theory this would be as simple as adding a simple command called dotnet-antlr that invokes java on the *.jar file with the right parameters.
The text was updated successfully, but these errors were encountered: