roslyn

Roslyn Analyzer Rule does not fail the build

半腔热情 提交于 2019-12-19 06:12:27
问题 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#

Roslyn Analyzer Rule does not fail the build

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 06:12:19
问题 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#

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

一个人想着一个人 提交于 2019-12-19 05:06:23
问题 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? 回答1: 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

List of breaking changes in Roslyn

时光总嘲笑我的痴心妄想 提交于 2019-12-19 03:57:07
问题 After switching to Visual Studio 2015, we have noticed that some changes made to how lambdas are compiled to MSIL in Roslyn (described in this thread and on GitHub) introduce runtime failures under certain conditions. Since Roslyn is obviously the future of .NET, we would like to switch to this technology, but it seems that all legacy code which has been running in production (and where we have a fair degree of confidence it works correctly) is now prone to new runtime failures. These are

How can I resolve all references with Roslyn's OpenSolutionAsync?

倖福魔咒の 提交于 2019-12-19 03:18:24
问题 I'm trying to open RoslynLight.sln with OpenSolutionAsync then iterate through all the projects. For my purposes I need a semantic model and resolved references. Through a combination of this issue and this question, I've arrived at this partial solution: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.MSBuild; using System.IO; namespace OpenRoslyn { class Program {

Roslyn Add a document to a project

淺唱寂寞╮ 提交于 2019-12-18 13:20:34
问题 I'm running roslyn ctp2 I am attempting to add a new html file to a project IWorkspace workspace = Workspace.LoadSolution("MySolution.sln"); var originalSolution = workspace.CurrentSolution; ISolution newSolution = originalSolution; newSolution.GetProject(newSolution.ProjectIds.First()) .AddDocument("index.html", "<html></html>"); workspace.ApplyChanges(originalSolution, newSolution); This results in no changes being written. I am trying to get the new html file to appear in VS 回答1: There are

Adding custom attributes to C# classes using Roslyn

我们两清 提交于 2019-12-18 12:23:41
问题 Consider the following class in a file "MyClass.cs" using System; public class MyClass : Entity<long> { public long Id { get; set; } [Required] public string Name { get; set; } public string Slug { get; set; } public DateTime CreatedOn { get; private set; } public DateTime UpdatedOn { get; private set; } /* ... */ } Currently I manually create data contract classes looking as follows: [DataContract(Namespace = "http://example.com/", Name = "MyClass")] public sealed class MyClass { [DataMember

Numerous instances of VBCSCompiler.exe

假如想象 提交于 2019-12-18 10:32:26
问题 I just recently downloaded and installed Visual Studio Professional 2015 (14.0.23107.0). The first time I opened up our solution (28 projects) and performed a Build -> Rebuild Solution, my development machine came to an absolute crawl. The CPU was maxed out at 100% and the build never completed - even after > 10 minutes. I opened up Windows Task Manager and noticed: > 10 VBCSCompiler.exe tasks running. When combined, these tasks sent the CPU > 90%. Any idea why there are so many of these

How to add white space and/or format code?

拈花ヽ惹草 提交于 2019-12-18 04:39:08
问题 Given that I have created a symbol using SymbolFactory.CreateProperty, how would I add white space. Currently I get accessibility, modifiers, name, type etc. all stringed together when writing out document. Maybe I am writing it out wrong, or I need to add extra step to add white space? I use document.GetText() to write it out to console. 回答1: Nope, that's what you expect. Generated nodes don't have whitespace, with the intent you'll process it once you're done. There are two options: Call

No C# 6.0 in Visual Studio 2015 CTP?

ⅰ亾dé卋堺 提交于 2019-12-17 22:46:31
问题 I have just created a new VM on Azure (using the image provided by the Azure team from the gallery) with CTP version of the upcoming Visual Studio 2014 that appeared yesterday online to test it and especially to play around with new C# 6.0 features. However, it does not provide support for C# 6.0 out of the box, for none of the language extensions (primary constructors, property initializers, safe navigation operator) work there. A blog entry on MSDN suggests adding the following to project