Skip to main content
Filter by
Sorted by
Tagged with
5 votes
1 answer
743 views

I'm implementing a custom Roslyn Analyzer whose ruleset would override a currently existing rule shipped by default with Visual Studio. Is there some way to make my rule silence this other rule in ...
silkfire's user avatar
  • 26.3k
1 vote
1 answer
988 views

After spending way too much time, I still can't make Roslyn to load simple C# project. Project source: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <...
Giedrius's user avatar
  • 8,610
3 votes
1 answer
1k views

I'm building a roslyn analyzer/code fix but I wan't to access the MSBuild Properties and metadata (both from Directory.build.props and the .csproj) in order to know how to apply the code fix. I only ...
LoadIt's user avatar
  • 137
2 votes
1 answer
740 views

I'm trying to test source generator. Generator: [Generator] public class CustomGenerator : ISourceGenerator { public void Initialize(GeneratorInitializationContext context) { } public void ...
Oleg's user avatar
  • 1,468
1 vote
1 answer
2k views

i am working on source generator and i need to read properties data type as string Is there any solution to get data type name such as int, string, bool, etc...? EDIT: var typeName = property.Type....
Daniel's user avatar
  • 101
2 votes
2 answers
738 views

I have a string that contains C# code. How can I check that the C# code in the string is valid C# and doesn't contain build errors? I'd like to do this programmatically in C#. I don't expect the code ...
F Chopin's user avatar
  • 738
7 votes
3 answers
2k views

Is there a way to find out whether class is partial inside Roslyn analyzer? There is a PartialImplementationPart in IMethodSymbol, but nothing similar for INamedTypeSymbol. I'm writing a Source ...
maxc137's user avatar
  • 2,841
1 vote
1 answer
362 views

I'm trying to understand why this test fails with: Maak.Test.InitializeNewUnitTest.NoPropertiesInitialized_Diagnostic Assert.AreEqual failed. Expected:<37>. Actual:<38>. Context: ...
ʃʈɑɲ's user avatar
  • 2,694
0 votes
1 answer
348 views

I want to get the approximate size of a struct that is passed as a parameter to a method. I am using a Roslyn analyzer. We want to check that structs passed in by value are not larger than 128 bytes. ...
Tomáš Oplatek's user avatar
1 vote
1 answer
1k views

I want to analyze whether a class implements a specific interface, concrete I am looking if the class implements IEquatable<T> and if so I want to raise a report. eg: class MyClass : ...
Christoph's user avatar
  • 448
8 votes
1 answer
1k views

You can find the full source code at https://github.com/myblindy/GrimBuilding/tree/efcore (the efcore branch). I understand that source generators can't automatically harvest dependencies from nuget ...
Blindy's user avatar
  • 68k
2 votes
2 answers
2k views

I try to accomplish using a Nuget Package in dynamic compiled code using Roslyn Compiler. I want to use a Nuget Package ( in my example https://www.nuget.org/packages/TinyCsvParser/ ) within my code. ...
Markus's user avatar
  • 685
1 vote
1 answer
826 views

I have this: /// <summary> /// Foo /// </summary> /// <seealso href="https://www.example.com/foo?q=bar&qux=2"/> That gives: XML comment has badly formed XML -- '...
lonix's user avatar
  • 22.4k
5 votes
0 answers
847 views

I would like to help prevent our dev team from not using our structured logging set up. The correct way to log (for us) would be like this: _logger.LogInformation("This is a message template with ...
Roarke's user avatar
  • 106
0 votes
1 answer
257 views

We are using the Microsoft.CodeAnalysis.NetAnalyzer and StyleCop.Analyzer roslyn Analyzers in our solutions to check code quality. We've been asked to provide evidence that we run these analyzers to ...
Efrain's user avatar
  • 3,374
3 votes
0 answers
304 views

I'm writing a Roslyn analyzer to check that a target type for JSON deserialization follows a few rules. In essence, if type Foo occurs in the expression JsonConvert.DeserializeObject<Foo>, then ...
Einar's user avatar
  • 312
1 vote
1 answer
451 views

I wanted to know how do I disable all roslyn analyzers in entire solution during debug mode but keep them enable in release mode? I can find references to disable them permanently or individually.
Prakash Kumar's user avatar
1 vote
2 answers
822 views

I have added some analyzer via NuGet in my solution. How to get all added analyzer rules from NuGet references? I need the ID (e.g. CA1001) and descriptions of all my enabled analyzers. EDIT: I need ...
p__b_o's user avatar
  • 71
0 votes
1 answer
139 views

As the title says, how do I ask Roslyn to generate an identifier for me, similar to how the pattern matching code fixer or the generate method ones do?
Blindy's user avatar
  • 68k
0 votes
1 answer
1k views

Throughout Visual Studio Solution with multiple projects, I have code snippets similar to: sqlCommand.CommandText = "Some SQL statement"; I am able to obtain all references to CommandText ...
Nenad's user avatar
  • 27k
1 vote
0 answers
1k views

I am using SonarQube 8.7.1 & visual studio 2019. As per requirement, we are to create a custom c# rule for sonar. I wrote a C# Roslyn analyzer. It works fine and working as expected. When I try to ...
Pankaj Kumar's user avatar
1 vote
1 answer
1k views

I have an application that allows users to write c-sharp code that gets saved as a class library for being called later. A new requirement has been established that some namespaces (and the methods ...
GrantA's user avatar
  • 590
0 votes
0 answers
156 views

Consider the code below. MySolutuion.sln using System; using System.Linq; using Microsoft.Build.Locator; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using ...
momo's user avatar
  • 3,581
1 vote
1 answer
903 views

I have a Unity 2020.2.1f1 project using Rider 2019.1.3 for the IDE. I installed the Microsoft.Unity.Analyzers (1.10.0) for it by basically following the tutorial published by Unity (https://docs....
birdyedwards's user avatar
0 votes
1 answer
703 views

Scenario 1 (Good): Create new VisualStudio solution by Class-Library (.Net Standard 2.0) template. Install any nuGet-package to it (e.g. Newtonsoft.Json) Right click on project, Properties -> ...
user1234567's user avatar
  • 4,371

1
3 4
5
6 7
17