2,928 questions
1355
votes
61
answers
889k
views
Could not find a part of the path ... bin\roslyn\csc.exe
I am trying to run an ASP.NET MVC (model-view-controller) project retrieved from TFS (Team Foundation Server) source control. I have added all assembly references and I am able to build and compile ...
217
votes
5
answers
85k
views
Can the C# interactive window interact with my code?
In Visual Studio 2015 or later, I can open the 'C# interactive window', and run code:
> 5 + 3
8
That's cute. Now how can I interact my code—my classes? Assume I have a project open.
> new Cog()...
140
votes
2
answers
25k
views
Is nameof() evaluated at compile-time?
In C# 6, you can use the nameof() operator to get a string containing the name of a variable or a type.
Is this evaluated at compile-time, or at runtime via some Roslyn API?
136
votes
5
answers
52k
views
VS2015 build fails with no error message with Dynamic
I was writing a unit test on a piece of code that returned JSON. The type that it returns is an anonymous type, so I thought to verify the values on it I'd just cast the object to a dynamic to do my ...
122
votes
5
answers
38k
views
Microsoft Roslyn vs. CodeDom
From a press release yesterday on InfoWorld regarding the new Microsoft Roslyn:
The most obvious advantage of this kind of "deconstructed" compiler is
that it allows the entire compile-execute ...
100
votes
5
answers
29k
views
Using System.Dynamic in Roslyn
I modified the example that comes with the new version of Roslyn that was released yesterday to use dynamic and ExpandoObject but I am getting a compiler error which I am not sure how to fix. The ...
95
votes
4
answers
8k
views
Roslyn failed to compile code
After I have migrated my project from VS2013 to VS2015 the project no longer builds. A compilation error occurs in the following LINQ statement:
static void Main(string[] args)
{
decimal a, b;
...
92
votes
5
answers
72k
views
What / why is Roslyn "needed" in /bin folder of ASP.nET
There are a bunch of related questions on this, though most of the answers define Roslyn and/or provide a "fix" to some issue (exe, with hosting providers, etc.)
What I can't seem to track ...
76
votes
6
answers
33k
views
Can not delete \bin\roslyn\VBCSCompiler.exe - Access is denied
I am facing a strange issue from roslyn compiler. Sometimes when I build the solution I face a strange issue in error list which does not let me build the solution. Here is the error:
Severity ...
73
votes
1
answer
5k
views
How can I make my code diagnostic syntax node action work on closed files?
I'm building a set of code diagnostics using Roslyn (in VS2015 Preview). Ideally, I'd like any errors they produce to act as persistent errors, just as if I were violating a normal language rule.
...
67
votes
2
answers
13k
views
C# 7.3 Enum constraint: Why can't I use the nullable enum?
Now that we have enum constraint, why doesn't compiler allow me to write this code?
public static TResult? ToEnum<TResult>(this String value, TResult? defaultValue)
where TResult : Enum
{
...
61
votes
2
answers
18k
views
Specifying locale for string interpolation in C#6 (Roslyn CTP6)
String interpolation in C#6 lets me write:
decimal m = 42.0m;
string x = $"The value is {m}";
However, a very common use case for string formatting is to specify the locale used for formatting the ...
60
votes
1
answer
2k
views
Why does this code crash Visual Studio 2015?
For some reason, even so much as typing this into a C# file in Visual Studio is enough to cause it to instantly crash. Why?
unsafe struct node {
node*[] child;
}
It seems to occur when the IDE ...
55
votes
9
answers
73k
views
How do I disable all Roslyn Code Analyzers?
I'm trying to work with a large opensource project that has a handful of Roslyn Code Analyzers. When I open the solution Visual Studio uses ~35% CPU for about 15 minutes. Using PerfView I've figured ...
52
votes
2
answers
103k
views
Why do we get possible dereference null reference warning, when null reference does not seem to be possible?
Having read this question on HNQ, I went on to read about Nullable Reference Types in C# 8, and made some experiments.
I'm very aware that 9 times out of 10, or even more often, when someone says "I ...
50
votes
3
answers
6k
views
How to modify code before compilation?
Using Roslyn, I would like to modify my C# code before the actual compilation. For now, I will just need something like:
[MyAnotatedMethod]
public void MyMethod()
{
// method-body
}
And based ...
47
votes
2
answers
35k
views
How to compile a C# file with Roslyn programmatically?
I read that you can't compile C# 6.0 with CSharpCodeProvider and therefor trying to do with with Roslyn. But I can't find a good example how to load a file and then compile it to a dll.
How should I ...
44
votes
3
answers
15k
views
Dynamic reference in a .net core app targeting net standard 1.6?
I'm trying to use a dynamic variable in a C# .net core app that's targeting .net standard 1.6. (platform? library? framework? meta-framework?) I first encountered this problem in a real application, ...
42
votes
5
answers
10k
views
Was C# compiler written in C++?
Was C# compiler written in C++?
40
votes
1
answer
17k
views
What's the difference between .NET CoreCLR, CoreRT, Roslyn and LLILC?
Recently I started reading about .NET reorganization details (mostly through .NET Core GitHub pages).
It seems that they created sibling projects to support more platforms. While reading I have the ...
38
votes
1
answer
8k
views
Why are there so many implementations of Object Pooling in Roslyn?
The ObjectPool is a type used in the Roslyn C# compiler to reuse frequently used objects which would normally get new'ed up and garbage collected very often. This reduces the amount and size of ...
36
votes
3
answers
5k
views
Null propagation operator and extension methods
I've been looking at Visual Studio 14 CTP along with C# 6.0 and playing with the null-propagation operator.
However, I couldn't find why the following code does not compile. The features are not yet ...
33
votes
3
answers
11k
views
Roslyn has no reference to System.Runtime
I'm working on a project where we are using Roslyn to compile some templates for us.
Now when I'm compiling the template I'm receiving multiple errors in the CompileResult.Diagnostics.
The errors are:...
32
votes
5
answers
24k
views
Is there code generation API for TypeScript?
When I needed to generate some C# code, for example DTO classes from xsd schema, or an excel table, I've used some roslyn API's.
Is there something simmilar for typescript?
[EDIT]: I've end up using ...
31
votes
2
answers
4k
views
Delegate caching behavior changes in Roslyn
Given the following code:
public class C
{
public void M()
{
var x = 5;
Action<int> action = y => Console.WriteLine(y);
}
}
Using VS2013, .NET 4.5. When looking ...