Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [roslyn]

A version of the C# and VB compilers that is written in managed code.

2
votes
1answer
140 views

Roslyn analyzer, converted from C# to F#

I'm learning F# and for an exercise, I took a roslyn analyzer in C# and ported it to F#. In the excerpt below the GetParameterInfo function: takes in ...
5
votes
2answers
1k views

Make compiler obfuscate strings

I'm looking at a task to obfuscate strings in my application like URLs, paths and queries at compile time. This is not for encrypting ...
2
votes
1answer
159 views

Getting the previous sibling of a node using Roslyn [closed]

I am currently creating an analyzer using the roslyn sdk. I ran into a case where it was simpler to check child tokens for Wait()/.Result. The code i am sharing works perfectly fine - However i was ...
12
votes
1answer
280 views

Field Can Be Made Readonly

Here is my Field Can Be Made Readonly analyzer and quick fix. I would appreciate tips on how to improve my code, and on missed test cases. First, the rules it works with: It will only fire on ...
2
votes
1answer
735 views

Adding an attribute to a class after the documentation comment trivia

I am trying to turn ...
7
votes
1answer
575 views

Removing XML Doc Comment Nodes

I recently wrote a code fix to handle many of the C# and VB.NET compiler diagnostics that was merged into Roslyn. Because it handles both, I implemented it as an abstract class with only the sections ...
5
votes
1answer
366 views

Detect and Fix Switching over an Enum Without Handling all Members

VSDiagnostic's latest refactoring and code fix detects when a switch does not contain case statements for each of the ...
6
votes
1answer
439 views

Add Missing XML Doc Parameters

This is an analyzer and code fix for VSDiagnostics that detects when a doc comment on a method does not have all parameters listed. When the user tells it to provide the fix, it adds a ...
14
votes
1answer
815 views

Adding compile-time format validation to your string.Format calls

I've written another diagnostic for VSDiagnostics that adds compile-time security for your formatting specified in a string.Format call. The exact scenario it ...
8
votes
1answer
297 views

Code Fix - changing accessibility

I am trying to get the hang of Roslyn at the moment, and to implement a couple of code fixes for specific fields/properties that should usually be readonly (in the case of a property, to have no ...
12
votes
1answer
731 views

Remove Empty Argument Lists from Attributes

I converted a C# analyzer for removing empty argument lists from attributes to be a C# and VB.NET analyzer: ...
8
votes
2answers
202 views

Putting everything in its place

A new diagnostic has seen the light of day! This one will alert you when you have a string.Format() call where the formatting placeholders are in the wrong order. ...
4
votes
2answers
437 views

Tool to Add Access Modifiers to Code

Working on VSDiagnostics, I implemented a tool that adds the default access modifiers to C# code. An example use would be starting with this: static class Foo { } ...
8
votes
3answers
516 views

Analyzing naming conventions

I just created a naming convention analyzer + code fix based on the Roslyn platform. The implemented naming conventions are the following: If you're interested in seeing all the test scenarios that ...
8
votes
2answers
3k views

Using Roslyn to find interfaces within a solution

The intent of the below code is to find all interfaces within a solution whose fully-qualified names match the given predicate. It seems to work, but as I am new to Roslyn I'm guessing there are ...
7
votes
1answer
332 views

CodeFixProvider that instantiates collections

Another piece of Roslyn-based code, this time a CodeFixProvider. I'm looking for feedback on Roslyn-specific code: Am I using the ...
14
votes
2answers
1k views

DiagnosticAnalyzer for Roslyn that guards against catch-all exception clauses

Dabbling around with Roslyn and made a small analyzer just now. This one will show a warning in Visual Studio when you have a try-catch statement that only has a ...