I. Write a comprehensive report on Roslyn Analyzers and FxCop Analyzers. Your report must fulfil the following requirement, [10 marks]
a) Snapshot for the installation of the latest version of Roslyn Analyzers and FxCop Analyzers.
b) List the core features of Roslyn Analyzers.
c) List the core features of FxCop Analyzers.
d) Write a simple CRUD application in C#.
e) Run the Roslyn Analyzers on your application source code to generate the analysis report. Include the snapshot of the result in your report.
f) Fix the violations reported by Roslyn Analyzers. Include the snapshot of the result in your report after fixing all the issues.
g) Run the FxCop Analyzers on your application source code to generate the analysis report. Include the snapshot of the result in your report.
h) Fix the violations reported by FxCop Analyzers. Include the snapshot of the result in your report after fixing all the issues.
i) Write a section in your report to discuss the advantages and disadvantages (if any) of using Roslyn and FxCop Analyzer
Roslyn, the .NET compiler platform, helps you catch bugs even before you run your code. One example is Roslyn’s spellcheck analyzer that is built into Visual Studio. Let’s say you are creating a static method and misspelled the word static as statc. You will be able to see this spelling error before you run your code because Roslyn can produce warnings in your code as you type even before you’ve finished the line. In other words, you don’t have to build your code to find out that you made a mistake.
Let me introduce you to Roslyn analyzer packages. These collections of analyzers provide a more verbose analysis, but don’t ship with the default Visual Studio tools. To learn more about our favorite Roslyn analyzers visit our Roslyn analyzers GitHub repository. This repository includes the FxCop rules that are still applicable to modern software development, but now target our modern code analysis platform based on Roslyn. Let’s go ahead and install this package to be more productive and write better code faster!
To Install FxCop analyzers as a NuGet package:
Once you have the package installed you can simply customize the analyzer diagnostics from the Solution Explorer. An analyzer node will appear under the References or Dependencies node in the Solution Explorer. If you expand the analyzers, and then expand one of the analyzer assemblies, you can see all the diagnostics in the assembly.
You can view the properties of a diagnostic, including its description and default severity, in the properties window. To view the properties, right-click on the rule and select Properties, or select the rule and then press Alt+Enter.
The icons next to each diagnostic in Solution Explorer correspond to the icons you see in the rule set when you open it in the editor:
You can then set the rule set severity from the Solution Explorer. In the Solution Explorer, expand Dependencies > Analyzers. Expand the assembly that contains the rule you want to set the severity for. Right-click on the rule and select Set Rule Set Severity and in the fly-out menu, select one of the severity options.
If you set the rule severity to a warning you will then receive a warning in your code for that specific rule set.
FxCop analyzers analyze source code in real time and during compilation, whereas legacy FxCop is a static code analysis and analyzes binary files after build has completed
Deprecated FxCop functions perform analysis after building a compiled assembly. In this case, the separate executable file FxCopCmd.exe is launched. The FxCopCmd.exe tool downloads the compiled assembly, analyzes the code, and then reports the results (or diagnostic data).
.NET analyzers are based on the .NET Compiler Platform ("Roslyn"). They can be included from the .NET SDK, or installed as a NuGet package referenced by a project or solution. Analyzers run analysis based on source code at compiler runtime. Analyzers are placed in the compiler process: csc.exe or vbc.exe, and perform the analysis when the project is built. The results of the analyzer operation are displayed together with the results of the compiler execution.
Comments
Leave a comment