how c# compiler works? [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
how c# compiler works??
how it parses our whole solutions and .cs files... i want to know where it start and how everything works... i want to know from the asp.net perspective...
thx

If you're really interested in how a C# compiler works, you may want to read the source code from Mono's compiler, mcs.

Eric Lippert gave a great synopsis of the C# compiler in this answer.

A really brief explanation could be:
In Asp.net, you write an page.aspx file that get compiled into a .Net assembly, this assembly is then used by the Asp.Net runtime that execute http request.
This .Net assembly can be written in any .Net language like c# or VB.Net. But in the end, the code is compiled by the .Net CLR compiler into a Common Intermediary Language(CIL). This CIL is used by the CLR runtime which get loaded when you start a .Net process. The JIT then use this CIL and transform it into pure assembly that will be understandable by the computer.

Related

Can I know how the language interoperability works in .NET with the help of example? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I was reading about the .NET framework and I read that ".NET provides language interoperability", and I also read the answer to the question What is language interoperability (basic concept) in .net framework?, but I don't have any idea about how to use this feature practically.
Create a simple project using C#, make a simple class and compile it. You will generate a .dll.
Then create a project using VB and import/include the one you compiled where you used C#. VB won´t take care of your C# code, but it can manage the class you created.
How? Because .NET is compiled in a common language. Does not matter if you have used C# or VB to generate the code.
Interoperability is a framework feature. Is rare that you need make use of this for small projects so I undestand you don't find a real way to carry out. But it is that simple as all what you do with C# in .NET you can reuse if you decide code in VB in the future or for some parts of a project.
In practice programmers decide to code in one language. But reusability is already there.
Feel free to ask what you need.
https://stackoverflow.com/a/43417187/7733724

What are the processes that the .net compiler does in order to compile code? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
first I want to say that I'm not sure if this is the best stack-exchange site to post this type of question but I'm not sure where it would fit the best. Anyway as the questions title's says I want to know the steps the .net compiler does when converting my C# code to a machine language one. I've watched some videos however there are some stuff that I still don't quite understand. I will leave all my question's at the bottom and I will try to be as specific as possible.
Here's my understanding of how the .net compiler works
My C# code -> IL -> JIT -> Assembler code
What is the exact term of "My C# code" ?
What is the use of CLR in here ?
Is this entire process handled by the CLR or where does it even comes in ?
What is Metadata ?
Is there something additional that happens in between those transition from step 1 to step 2 and from step 2 to step 3 or it's just some code being translated to a lower-level language ?
Just C# (C# -> Roslyn (or csc) -> IL -> JIT -> Native)
The CLR is what reads your IL, JIT's it and holds the GC (and much, much more that doesn't pertain to this question)
The CLR only runs your compiled code. C# compilation is done through a normal compiler (which was csc.exe, but is now deprecated by Roslyn).
There are plenty of examples that state what Metadata is
There is a lot that goes on in those steps, but that is the primary flow.

Is there any way to use python script under Xamarin.Android? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know CSharp is the language in Xamarin,but sometimes some features of python are awesome,so I want invoke python scripts under Xamarin.
I know ironpython,so I try it.
I added some Required Assembly like: IronPython.dll,IronPython.Module,Microsoft.Scripting.dll...
Luckily,I built it successfully and it run on my Android device.
But When the code run at:
ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
ScriptSource source = engine.CreateScriptSourceFromString("");
source.Execute(scope);
An error occured:
Microsoft.Scripting.InvalidImplementationException:
Type 'IronPython.Runtime.PythonContext' doesn't provide a suitable public constructor or its implementation is faulty:
Could not load type 'IronPython.Runtime.PythonContext' from assembly 'IronPython, Version=2.7.5.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1'.
So,Is there any possibility to use Python Scripts on Xamarin.Android?
Short answer, No. You could conceivably port IronPython or some other Python runtime to work under Xamarin, but that would take considerable effort, and to my knowledge it hasn't been done before.
People have asked this before, but no, the crux of Xamarin is C# (or F#) so anything else is out of scope. Am sure other people are trying to do similar things with other languages like Python, but not through Xamarin

How to convert c# DLL to vb DLL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Please, can I convert a c# DLL to vb DLL, My problem is when I try to use svg.dll written in c# with a vb Code, Single and Float Types don't much, Any Help or suggestion !
Good news: There is no need to convert! A .NET DLL is neither a C# DLL nor a VB.NET DLL, it's simply a .NET DLL. You can use DLLs created with C# in VB.NET and vice-versa.
(Apparently, you have some specific issue using a third-party DLL. Now that you know that "the language of the DLL" is not the problem, I suggest that you start a new question about that and explain the problems you are having in detail. Beware of the XY problem!)

What's the relationship between Mono Cecil and NRefactory and how to compare them to Roslyn? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I understand that Microsoft's Compiler as a Service or Roslyn project was inspired by Mono Cecil.
But what's the relationship between Mono Cecil and NRefactory? Does one use the other? Or are they alternative technologies that do the same thing?
It appears that both of them provide the same slew of code analysis services, just like Roslyn.
You got some misunderstanding.
Roslyn was a private project, when Mono guys were turning their C# compiler to a service (Mono.CSharp assembly). If you read this post by Miguel you can learn more about what happened in 2008.
The two happened to be announced together on the same Microsoft PDC event (Anders's session first, and then Miguel's session). So Roslyn has some relationship with Mono.CSharp, but no relationship with Cecil.
Microsoft does have another project which is similar to Cecil, called CCI
Cecil is a MSIL reader and writer, while NRefactory primarily is C# parser and AST framework. NRefactory depends on Cecil as stated in README, as well as Mono.CSharp.
But we should see that if we do code analysis based on Cecil, we are on MSIL layer, and such analysis applies to in fact all .NET languages (including VB.NET, Oxygene and so on). If the code analysis is based on NRefactory then it more focuses on C# layers.
Comparing Mono bits with Roslyn should be avoided at this moment, as we are not sure how Roslyn looks like when it is finalized and published by Microsoft. To me, Roslyn should be equivalent to a stack of libraries on Mono (including Cecil, NRefactory, Mono.CSharp, and IKVM.Reflection).

Categories