roslyn

VS 2015, C# 6, MVC5, Roslyn — 502 gateway and compilation errors on Azure web app

耗尽温柔 提交于 2019-12-12 03:45:34
问题 I have a question that is very similar to this: VS 2015, C# 6, MVC5, Roslyn -- 502 gateway errors on Azure web app so please don't mark this as a duplicate. My situation is exactly the same as in that previous question: VS 2015, C# 6, MVC5, Roslyn, very slow website with 502 gateway errors, CodeDOM compiler Nuget package, Azure Web App with git continuous deployment. Additionally, I am getting compilation errors like this: Server Error in '/' Application. Compilation Error Description: An

MEF With Portable Class library using Microsoft Composition MEF2 throws file not found exception

浪子不回头ぞ 提交于 2019-12-12 02:53:16
问题 I am working on Portable Class Library(PCL) and trying to achieve MEF in that. I used System.Composition from Nuget. When i build and package for vsix (Extension for Visual Studio) it doesn't package and place those dll's to extension folder (C:\Users\UserName\AppData\Local\Microsoft\VisualStudio\14.0Exp\Extensions\ExtensionName\AppName\versionofYourApp). When i manually place those library in this folder it works fine. Can some one suggest a good solution to this problem. I am writing it for

Find classes which derive from a specific base class with Roslyn

僤鯓⒐⒋嵵緔 提交于 2019-12-12 00:08:22
问题 On this page following code is suggested to find classes which derive from a given type, but this code does not work because following line var symbol = _model.GetDeclaredSymbol(node); returns ISymbol, rather than expected INamedTypeSymbol. On the answers to FAQs on this page , for getting the type of a variable declaration, following piece of code is suggested. However, this also throws an exception in run-time, saying that cast to ILocalSymbol is not valid. var type = ((ILocalSymbol)model

Symbol from ReferenceLocation?

℡╲_俬逩灬. 提交于 2019-12-11 23:25:38
问题 I'm trying to write some code using Roslyn that verifies some architectural layering constraints to aid some assembly consolidation. i.e.: * An internal type, must be in an .Internal suffixed namespace. * A use of a 'X.Y.Z.Internal' type is only allowed from the X.Y.Z namespace. The simplest looking approach to solve this problem is to find all internal types via enumeration as per FAQ(9) and then utilize SymbolFinder to find all of the references and examine the containing type at the

Is Roslyn End User Preview still available?

a 夏天 提交于 2019-12-11 20:46:17
问题 On the Roslyn home page, there is a link for the "End User Preview" which takes you to the Microsoft Connect site. http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx Rather than seeing a form to complete, in order that I can download the end user preview, what I actually see is the "My Dashboard" area. So I search for "rosyln" in the "Product Directory' but no results appear. Is Roslyn still available for Visual Studio 2013 users as the end user preview, or since Visual Studio 2015 Preview

Using Roslyn scripting in UWP

☆樱花仙子☆ 提交于 2019-12-11 16:32:54
问题 I have the following segment of code. var script = CSharpScript.Create("int x = 12;"); var result = await script.RunAsync(); var variable = result.GetVariable("x"); int value = (int)variable.Value; It crashes on the second line with following: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) This is a UWP

How to work with BaseListSyntax, Roslyn

自作多情 提交于 2019-12-11 11:49:26
问题 Need to add inherite to some interface using roslyn. I describe the class, but don't know how to set inherite in the following structures: ClassDeclarationSyntax lClassDeclarationSyntax = Syntax.ClassDeclaration( Syntax.List<AttributeListSyntax>(lAttributeListSyntax), Syntax.TokenList(lTokens), Syntax.Identifier(_classInfo.Identifier.ValueText), null, null,--------- Syntax.List<TypeParameterConstraintClauseSyntax>(), Syntax.List<MemberDeclarationSyntax>(lMemberDeclarationSyntaxList));

How to use Roslyn Code Analysis API with MVC 6 projects

流过昼夜 提交于 2019-12-11 10:55:12
问题 I intend to use the new Roslyn Code Analysis API with an MVC 6 project. However, when I run this code: string pathToSolution = @"..\..\..\WebApplicationComplex.sln"; const string projectName = "RoslynWebAPIProject"; MSBuildWorkspace workspace = MSBuildWorkspace.Create(); Solution solutionToAnalyze = workspace.OpenSolutionAsync(pathToSolution).Result; Project sampleProjectToAnalyze = solutionToAnalyze.Projects.Where((proj) => proj.Name == projectName).FirstOrDefault(); Compilation

'Expected Global Line.' exception while loading solution using Roslyn

拟墨画扇 提交于 2019-12-11 10:46:27
问题 I'm learning Roslyn and trying it out for the first time. I've written a small code snippet to load a solution and get a reference to a workspace. IWorkspace workspace = Workspace.LoadSolution(solutionPath); foreach (IProject project in workspace.CurrentSolution.Projects) { CommonCompilation objCompilation = project.GetCompilation(); } return workspace; But I'm getting an exception in the first line. The exception details are given below. Message : Expected Global Line. stack trace : at

Roslyn Workspace API : Emiting Wpf and Silverlight Projects

不羁岁月 提交于 2019-12-11 07:54:54
问题 I try Emit each project in this solution. I wonder why there is a problem with Emiting "Wpf" and "Silverlight" projects. I can understand that I can't Emit Console Project that I am currently executing. How I can add missing references? Here is my code.: public static async Task EmitProject(Project proj) { var c = await proj.GetCompilationAsync(); var r = c.Emit("my" + proj.Name ); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(r.Success + " " + proj.Name); if (!r.Success) {