This question already has answers here:
Compiler #if directive to split between Mono and .NET [duplicate]
(3 answers)
Closed 8 years ago.
Because Mono doesn't support some windows functions in .NET, is there any pre-compiler derivative that indicates that the compiler is a mono compiler?
Example, in Visual Studio there is a derivative #DEBUG and #TRACE is there such a derivative for mono that's something like `#MONO' that automatically is added if the compiler is mono?
Or do we have to add the derivative ourselves and change as necessary?
Mono compiler defines MonoCS, I think
So:
#if __MonoCS__
should work...
Related
This question already has an answer here:
Console.WriteLine vs Print
(1 answer)
Closed 4 years ago.
Debug.Log("Hello there!");
print("Hello there");
Both of the statements display the same output on the console, so what's the difference?
In native .NET Framework, neither of your examples exist. The closest functionality would be via either System.Diagnostics.Debug or System.Diagnostics.Trace.
If you're talking about Unity then behavior is identical:
Logs message to the Unity Console (identical to Debug.Log).
source
This question already has answers here:
How do I decompile a .NET EXE into readable C# source code?
(9 answers)
Closed 5 years ago.
I have an exe file which is written in .net language . I have no source code for same but I want to change some functionality in this so convert it to visual studio source code. is there any way to do this?
have a look on IL Spy-
https://www.gallery.expression.microsoft.com/8ef1d688-f80c-4380-8004-2ec7f814e7de
Also you can download it from here-
http://sourceforge.net/projects/sharpdevelop/files/ILSpy/2.0/ILSpy_Master_2.1.0.1603_RTW_Binaries.zip/download.
Just unzip the contents in a folder somewhere - no installer. Then run ILSpy.exe.
This question already has answers here:
Is it possible to embed C code in a C# project?
(4 answers)
Closed 6 years ago.
I have C++ legacy code with functions in the form:
double func(double)
I have this as a source file - it isnt in the form of a DLL although it could be turned into one if necessary
How can I call func in my C# code (maybe over managed C++)? I heard of Marshalling and DllImport but I did not find MSDN very helpful.
You have to compile C++ code as DLL library and then DllImport is way to go.
I don't know what problem you have with it. On MSDN I found this https://msdn.microsoft.com/en-us/library/e59b22c5.aspx
And also this article: http://www.mono-project.com/docs/advanced/pinvoke/ seems to be quite useful.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I conditionally compile my C# for Mono vs. Microsoft .NET?
I have sqlite in my project and I'd like to run it in mono. The code is exactly the same for mono and nonmono however mono needs me to include a different namespace. Does mono have a predefined macro? Right now i define USE_MONO. Is there an official definition i can use?
#if USE_MONO
using Mono.Data.Sqlite;
#else
using System.Data.SQLite;
#endif
(From the duplicate question) The mono compiler defines __MonoCS__ for this purpose so you can use:
#if __MonoCS__
using Mono.Data.Sqlite;
#else
using System.Data.SQLite;
#endif
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Parser for C#
Any (free) libraries that can parse C# source code and make a DOM of it?
I need to add an attribute to all classes in bunch of .cs files and then compile them to an assembly. This needs to be done in an asp.net application, so I'm not interested in Visual Studio plugins or similar.
I need to achieve this
input: ~/plugins/MyPlugin/MyPlugin.cs
public class MyPlugin : PluginBase, IEntitySavingPlugin
{
}
output: Plugins.dll
[PluginDirectory("~/plugins/MyPlugin/")]
public class MyPlugin : PluginBase, IEntitySavingPlugin
{
}
You can try to use Antlr Parser, a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions.
Support C#; C# 2 ;C# 3
http://www.antlr.org/
Duplicate of question Parser for C#.
Your best bet may be one of these:
http://csparser.codeplex.com/
http://wiki.sharpdevelop.net/NRefactory.ashx