roslyn

Is there a way to change fonts and colors for the C# Interactive window in the Roslyn CTP?

不打扰是莪最后的温柔 提交于 2019-12-01 05:49:05
It seems to have partially inherited fonts and colors from my current settings, which has made it pretty ugly right now. I looked in fonts and colors but there is no settings for C# Interactive. Disclaimer : I work for Microsoft on the Roslyn team. We have not done the polish work to create the logical and correct fonts and colors for the C# Interactive Window yet. In this case, the black text in your screenshot should using Text Editor->Plain Text, but it's not. Instead, it's using "Text Editor->Interactive Console - Black". If you change "Text Editor->Interactive Console - Black" to match

'Main' method not found when compiling through Roslyn

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 05:35:15
问题 I am using Roslyn to compile a solution with run-time generated code. While the solution compiles perfectly when opened from Visual Studio, it fails from Roslyn: error CS5001: Program does not contain a static 'Main' method suitable for an entry point The solution I am trying to compile has a single ASP.NET Core 2 (.NET Framework 4.6.2) project, which of course has a Main method in the Program class at the root of the project: public class Program { public static void Main(string[] args) {

SemanticModel.GetTypeInfo() for ObjectCreationExpressionSyntax.Type returns null

陌路散爱 提交于 2019-12-01 05:27:37
问题 I am trying to get type info from ObjectCreationExpressionSyntax object but failed. Here is example that reproduce the problem (see "ti.Type is null" in code): using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.MSBuild; namespace RoslynExample { class Program { static void Main(string[] args) { string solutionPath = @"..\..\..\RoslynExample.sln"; MSBuildWorkspace workspace = MSBuildWorkspace.Create();

Is there any way to get Members of a type and all subsequent base types?

雨燕双飞 提交于 2019-12-01 04:24:15
问题 I have an `ITypeSymbol' object. If I call GetMembers, it gives me the members of the current type, not the base. I know I can dig it using BaseType property and have some iterative code to fetch all the properties. Is there any easier way to fetch all members regardless of level at the inheritance hierarchy? 回答1: If you're looking for all members whether or not they're accessible: There is no public API to do this, and internally the Roslyn team's approach is more or less the same as what you

Asp.net MVC Razor view - CS1525: Invalid expression term '.'

纵然是瞬间 提交于 2019-12-01 04:17:14
I have two identical ASP.Net 4.6 MVC project, project 1 is using roslyn complier within the site which is working fine. c:\windows\system32\inetsrv>C:\Websites1\bin\roslyn\csc.exe Microsoft (R) Visual C# Compiler version 1.2.0.60325 With the second project I'm getting the error below, it's using the complier from .Net framework. c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" Microsoft (R) Visual C# Compiler version 4.6.1590.0 Line 6: @if (!Model?.Item?.IsDerived(Templates.PageMetadata.ID) ?? true) Line 7: { Line 8: return; c:\Website2\Views\metadata

Roslyn Analyzer Rule does not fail the build

牧云@^-^@ 提交于 2019-12-01 03:54:59
Following on from this tutorial from MS, I have created an analyzer for Roslyn. According to the page, you can mark the rule as DiagnosticSeverity.Error , and this will cause the build to break: In the line declaring the Rule field, you can also update the severity of the diagnostics you’ll be producing to be errors rather than warnings. If the regex string doesn’t parse, the Match method will definitely throw an exception at run time, and you should block the build as you would for a C# compiler error. Change the rule’s severity to DiagnosticSeverity.Error: internal static

Is there a way to change fonts and colors for the C# Interactive window in the Roslyn CTP?

馋奶兔 提交于 2019-12-01 03:19:42
问题 It seems to have partially inherited fonts and colors from my current settings, which has made it pretty ugly right now. I looked in fonts and colors but there is no settings for C# Interactive. 回答1: Disclaimer : I work for Microsoft on the Roslyn team. We have not done the polish work to create the logical and correct fonts and colors for the C# Interactive Window yet. In this case, the black text in your screenshot should using Text Editor->Plain Text, but it's not. Instead, it's using

What is the difference between using <DebugType>Full</DebugType> and <DebugType>Portable</DebugType> for .net core projects?

我们两清 提交于 2019-12-01 02:53:10
To generate open cover report I have to make debugType as Full. I generate report on build server as I have to fail the build if the coverage doesn't reach a certain threshold. The build is generated in Release mode. What consequence does keeping debugType Full in my csproj file have? Will it degrade the performance in production? The difference is that the "full" type emits a classic windows PDB symbol file which is complex and poorly documented. The "portable" PDB format is a new open-source format that can be created and used on all platforms. You can read more information on this format at

Creating new Microsoft.CodeAnalysis.CustomWorkspace - got ReflectionTypeLoadException

﹥>﹥吖頭↗ 提交于 2019-12-01 02:17:45
问题 I try to create something like ConsoleClassifier in .NET Compiler Platform ("Roslyn") Samples. (Microsoft.CodeAnalysis v0.7...) At this point I get a ReflectionTypeLoadException : CustomWorkspace workspace = new CustomWorkspace(); ReflectionTypeLoadException {"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."} LoaderExceptions: FileNotFoundException {"Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture

Why can't I throw exceptions from an expression-bodied member?

自闭症网瘾萝莉.ら 提交于 2019-12-01 02:06:42
Using expression-bodied members allows you to define the body of a method or property as a single expression without a return keyword (should it return something). For example it turns these int Method1() { return 5; } void Method2() { Console.WriteLine(); } into these int Method1() => 5; void Method2() => Console.WriteLine(); A difference comes into play when you throw an exception from the body: void Method3() { throw new Exception(); } However, the following will not compile: void Method3() => throw new Exception(); with the following messages: Warning The member 'Program.Exception()' does