-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mock.Of<T> and MockRepository support to ConstructorArgumentsShou…
…ldMatchAnalyzer (#140) The majority of this change is mechanical (moving code from one location to another, replacing magic strings with constants, etc.). There is a functional update that completely changes the `ConstructorArgumentsShouldMatchAnalyzer`: - consolidating two constructor analyzers now into a single shared source - improving the performance of the constructor analyzer - adding support for checking delegate - adding support for `Mock.Of<T>` and `MockRepository` features of `Moq` ![image](https://github.com/rjmurillo/moq.analyzers/assets/6811113/cf6e2e52-237c-4f5e-bdc8-dadb0026eeba) _Baseline is an empty analyzer, control is the old interface constructor parameter analyzer, treatment is the new combined analyzer._ Changes Misc: - Reduced severity of AV analyzer items (see #139) - Move magic strings to constants - Moved much of the common code into a `Common` folder and namespace Documentation: - Fixed links to documentation for shipped analyzers - In analyzer rule help, link to commit id so documentation snaps to the version of the analyzer Analyzers: - Moved rule ID to constants file - Added extension factory methods to help create `Diagnostic` - Consolidated two constructor parameter analyzers (Moq1001 and Moq1002) into a single analyzer with 30% better performance - `ConstructorArgumentsShouldMatchAnalyzer` now supports `Mock.Of<T>` syntax and `MockRepository` patterns Benchmarks: - Add the ability to have a control and treatment as well as "baseline", allowing A/B performance benchmarking of implementations - Added benchmark for `ConstructorArgumentsShouldMatchAnalyzer` Test: - Added extension methods to include all Moq versions under test or just the latest - Organized the `ConstructorArgumentsShouldMatchAnalyzer` test collateral (it's the highest volume) into partial files - Added Live Unit Test configuration when running in Visual Studio - Added code coverage filter for benchmark code if using ReSharper or Rider _Note: while code coverage is improved, it's still below 95%. This is due to some guard cases that need coverage. For example, #141_ Resolves #122 For Moq1001 and Moq1002, #85
- Loading branch information
Showing
49 changed files
with
1,355 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
## The .lutignore file is used by Live Unit Testing to ignore Visual Studio temporary files, build results, | ||
## and files generated by popular Visual Studio add-ons when creating a private copy of the source tree that | ||
## Live Unit Testing uses for its build. | ||
## | ||
## This file has same format as git's .gitignore file (https://git-scm.com/docs/gitignore). In fact, in the | ||
## case where a .lutignore file is not found, but a .gitignore file is found, Live Unit Testing will use the | ||
## .gitignore file directly for the above purpose. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.userprefs | ||
*.sln.docstates | ||
.vs/ | ||
.vscode/ | ||
.packages/ | ||
.dotnet/ | ||
.tools/ | ||
.idea/ | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Rr]elease/ | ||
[Bb]inaries/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
x64/ | ||
TestResults/ | ||
|
||
# Debug artifactss | ||
launchSettings.json | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.Publish.xml | ||
|
||
# NuGet Packages Directory | ||
packages/ | ||
|
||
# NuGet V3 artifacts | ||
[Nn]u[Gg]et.exe | ||
*-packages.config | ||
*.nuget.props | ||
*.nuget.targets | ||
project.lock.json | ||
msbuild.binlog | ||
*.project.lock.json | ||
|
||
# Miscellaneous | ||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.wrn | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.scc | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.[Pp]ublish.xml | ||
*.pfx | ||
*.publishsettings | ||
|
||
# Visual Studio cache files | ||
*.sln.ide/ | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
*.VC.opendb | ||
*.VC.db | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
*.ncrunch* | ||
.*crunch*.local.xml | ||
|
||
# Upgrade backups | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
App_Data/*.mdf | ||
App_Data/*.ldf | ||
|
||
#LightSwitch generated files | ||
GeneratedArtifacts/ | ||
_Pvt_Extensions/ | ||
ModelManifest.xml | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Mac desktop service store files | ||
.DS_Store | ||
|
||
# WPF temp projects | ||
*wpftmp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<LUTConfig Version="1.0"> | ||
<Repository /> | ||
<ParallelBuilds>true</ParallelBuilds> | ||
<ParallelTestRuns>true</ParallelTestRuns> | ||
<TestCaseTimeout>180000</TestCaseTimeout> | ||
</LUTConfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=Moq_002EAnalyzers_002EBenchmarks_003B_002A_003B_002A_003B_002A/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Moq.Analyzers.Common; | ||
|
||
internal static class CompilationOptionsExtensions | ||
{ | ||
/// <summary> | ||
/// Determines if the diagnostic identified by the given identifier is currently suppressed. | ||
/// </summary> | ||
/// <param name="compilationOptions">The compilation options that will be used to determine if the diagnostic is currently suppressed.</param> | ||
/// <param name="descriptor">The diagnostic descriptor to check.</param> | ||
/// <returns>True if the diagnostic is currently suppressed.</returns> | ||
internal static bool IsAnalyzerSuppressed(this CompilationOptions compilationOptions, DiagnosticDescriptor descriptor) | ||
{ | ||
switch (descriptor.GetEffectiveSeverity(compilationOptions)) | ||
{ | ||
case ReportDiagnostic.Suppress: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Moq.Analyzers.Common; | ||
|
||
internal static class DiagnosticCategory | ||
{ | ||
internal const string Moq = nameof(Moq); | ||
} |
Oops, something went wrong.