├── .gitignore ├── README.md ├── appveyor.yml └── src ├── Gmtl.CodeWatch.Tests ├── CodeWatchResultTests.cs ├── ExceptionHandlingWatcherTests.cs ├── ExcludedAssemblyTests.cs ├── ExcludedTypeTests.cs ├── FieldNamingWatcherTests.cs ├── FluentConfigurationTests.cs ├── Gmtl.CodeWatch.Tests.csproj ├── MaxConstructorParametersWatcherTests.cs ├── MaxMethodParametersWatcherTests.cs ├── MethodReturnTypeWatcherTests.cs ├── Properties │ └── AssemblyInfo.cs ├── PropertyNamingWatcherTests.cs ├── Samples │ ├── .gitignore │ ├── ExceptionTester │ │ ├── ExceptionTesterWithCatchAllHandledException.cs │ │ ├── ExceptionTesterWithCatchAllUnhandled.cs │ │ ├── ExceptionTesterWithHandledAndUnhandledException.cs │ │ ├── ExceptionTesterWithInheritedMethod.cs │ │ ├── ExceptionTesterWithParametrizedCatchExceptionV1.cs │ │ └── ExceptionTesterWithParametrizedCatchExceptionV2.cs │ ├── FieldNaming │ │ ├── FieldNaming.tt │ │ └── FieldNamingInheritance.cs │ ├── ManyParametersMethods │ │ └── ManyParametersMethods.tt │ ├── MethodReturnType │ │ ├── AllMethodsReturnIListOfType.cs │ │ └── MethodsReturnDifferntLists.cs │ └── PropertyNaming │ │ ├── PropertyNaming.tt │ │ └── PropertyNamingInheritance.cs ├── TestHelpers.cs └── packages.config ├── Gmtl.CodeWatch.sln ├── Gmtl.CodeWatch ├── CodeWatchException.cs ├── CodeWatchResult.cs ├── CodeWatcherConfig.cs ├── CodeWatcherContext.cs ├── Gmtl.CodeWatch.csproj ├── Gmtl.CodeWatch.nuspec ├── IWatcher.cs ├── LettersMap.cs ├── Naming.cs ├── Properties │ └── AssemblyInfo.cs └── Watchers │ ├── AbstractWatcher.cs │ ├── ExceptionHandlingWatcher.cs │ ├── FieldNamingFirstLetterWatcher.cs │ ├── MaxConstructorParametersWatcher.cs │ ├── MaxMethodParametersWatcher.cs │ ├── MethodReturnTypeWatcher.cs │ ├── PropertyNamingFirstLetterWatcher.cs │ └── TextBasedWatcher.cs ├── SampleProject ├── Gmtl.CodeWatch.SampleProject.Tests │ ├── GlobalContextTests.cs │ ├── Gmtl.CodeWatch.SampleProject.Tests.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── WatchAllTryCatchBlocksHandleException.cs │ ├── WatchFieldNamesInAssemblies.cs │ ├── WatchPropertyNamesInAssemblies.cs │ └── packages.config ├── Gmtl.CodeWatch.SampleProject.sln └── Gmtl.CodeWatch.SampleProject │ ├── DomainModel.cs │ ├── DomainService.cs │ ├── Gmtl.CodeWatch.SampleProject.csproj │ └── Properties │ └── AssemblyInfo.cs └── TestData ├── Gmtl.CodeWatch.TestData.AllUppercaseProperties ├── Class1.cs ├── Class2.cs ├── Class3.cs ├── Gmtl.CodeWatch.TestData.AllUppercaseProperties.csproj └── Properties │ └── AssemblyInfo.cs └── Gmtl.CodeWatch.TestData.MixedPropertyNames ├── Class1.cs ├── Class2.cs ├── Class3.cs ├── Gmtl.CodeWatch.TestData.MixedPropertyNames.csproj └── Properties └── AssemblyInfo.cs /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # Visual Studio code coverage results 114 | *.coverage 115 | *.coveragexml 116 | 117 | # NCrunch 118 | _NCrunch_* 119 | .*crunch*.local.xml 120 | nCrunchTemp_* 121 | 122 | # MightyMoose 123 | *.mm.* 124 | AutoTest.Net/ 125 | 126 | # Web workbench (sass) 127 | .sass-cache/ 128 | 129 | # Installshield output folder 130 | [Ee]xpress/ 131 | 132 | # DocProject is a documentation generator add-in 133 | DocProject/buildhelp/ 134 | DocProject/Help/*.HxT 135 | DocProject/Help/*.HxC 136 | DocProject/Help/*.hhc 137 | DocProject/Help/*.hhk 138 | DocProject/Help/*.hhp 139 | DocProject/Help/Html2 140 | DocProject/Help/html 141 | 142 | # Click-Once directory 143 | publish/ 144 | 145 | # Publish Web Output 146 | *.[Pp]ublish.xml 147 | *.azurePubxml 148 | # TODO: Comment the next line if you want to checkin your web deploy settings 149 | # but database connection strings (with potential passwords) will be unencrypted 150 | *.pubxml 151 | *.publishproj 152 | 153 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 154 | # checkin your Azure Web App publish settings, but sensitive information contained 155 | # in these scripts will be unencrypted 156 | PublishScripts/ 157 | 158 | # NuGet Packages 159 | *.nupkg 160 | # The packages folder can be ignored because of Package Restore 161 | **/packages/* 162 | # except build/, which is used as an MSBuild target. 163 | !**/packages/build/ 164 | # Uncomment if necessary however generally it will be regenerated when needed 165 | #!**/packages/repositories.config 166 | # NuGet v3's project.json files produces more ignoreable files 167 | *.nuget.props 168 | *.nuget.targets 169 | 170 | # Microsoft Azure Build Output 171 | csx/ 172 | *.build.csdef 173 | 174 | # Microsoft Azure Emulator 175 | ecf/ 176 | rcf/ 177 | 178 | # Windows Store app package directories and files 179 | AppPackages/ 180 | BundleArtifacts/ 181 | Package.StoreAssociation.xml 182 | _pkginfo.txt 183 | 184 | # Visual Studio cache files 185 | # files ending in .cache can be ignored 186 | *.[Cc]ache 187 | # but keep track of directories ending in .cache 188 | !*.[Cc]ache/ 189 | 190 | # Others 191 | ClientBin/ 192 | ~$* 193 | *~ 194 | *.dbmdl 195 | *.dbproj.schemaview 196 | *.jfm 197 | *.pfx 198 | *.publishsettings 199 | node_modules/ 200 | orleans.codegen.cs 201 | 202 | # Since there are multiple workflows, uncomment next line to ignore bower_components 203 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 204 | #bower_components/ 205 | 206 | # RIA/Silverlight projects 207 | Generated_Code/ 208 | 209 | # Backup & report files from converting an old project file 210 | # to a newer Visual Studio version. Backup files are not needed, 211 | # because we have git ;-) 212 | _UpgradeReport_Files/ 213 | Backup*/ 214 | UpgradeLog*.XML 215 | UpgradeLog*.htm 216 | 217 | # SQL Server files 218 | *.mdf 219 | *.ldf 220 | 221 | # Business Intelligence projects 222 | *.rdl.data 223 | *.bim.layout 224 | *.bim_*.settings 225 | 226 | # Microsoft Fakes 227 | FakesAssemblies/ 228 | 229 | # GhostDoc plugin setting file 230 | *.GhostDoc.xml 231 | 232 | # Node.js Tools for Visual Studio 233 | .ntvs_analysis.dat 234 | 235 | # Visual Studio 6 build log 236 | *.plg 237 | 238 | # Visual Studio 6 workspace options file 239 | *.opt 240 | 241 | # Visual Studio LightSwitch build output 242 | **/*.HTMLClient/GeneratedArtifacts 243 | **/*.DesktopClient/GeneratedArtifacts 244 | **/*.DesktopClient/ModelManifest.xml 245 | **/*.Server/GeneratedArtifacts 246 | **/*.Server/ModelManifest.xml 247 | _Pvt_Extensions 248 | 249 | # Paket dependency manager 250 | .paket/paket.exe 251 | paket-files/ 252 | 253 | # FAKE - F# Make 254 | .fake/ 255 | 256 | # JetBrains Rider 257 | .idea/ 258 | *.sln.iml 259 | 260 | # CodeRush 261 | .cr/ 262 | 263 | # Python Tools for Visual Studio (PTVS) 264 | __pycache__/ 265 | *.pyc 266 | 267 | # Cake - Uncomment if you are using it 268 | # tools/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gmtl.CodeWatch library 2 | 3 | ## Build Status 4 | 5 | [![Build status](https://ci.appveyor.com/api/projects/status/8v6omwnj1o4fdc2h?svg=true)](https://ci.appveyor.com/project/pawelklimczyk/codewatch) 6 | [![NuGet](https://img.shields.io/nuget/v/Gmtl.CodeWatch.svg)](https://www.nuget.org/packages/Gmtl.CodeWatch/) 7 | ## Idea 8 | 9 | Idea behind creating CodeWatch was to add quality layer in developed product. Developers may use different IDE and programming techniques in the same project. Some tools (like FxCop) are difficult to use outside expected IDE. Developers agree to follow "coding standards" and forget to do that later. 10 | 11 | This tool is not a panacea. It's rather a complementary piece that can help you achieve better code quality. It does not think on your behave, but automates it a little. 12 | 13 | 14 | ## What CodeWatch can solve? 15 | 16 | - Automates rules checking during unit/integration testing 17 | - Keep code conventions along with the project (in XML file) 18 | 19 | ## Examples 20 | 21 | 22 | All fields in given assembly has to be uppercase 23 | 24 | ``` 25 | [TestFixture] 26 | public class GlobalContextTests 27 | { 28 | [Test] 29 | public void FluentConfigurationBuilder() 30 | { 31 | CodeWatcherConfig config = CodeWatcherConfig.Create() 32 | .WithWatcher(c => new FieldNamingWatcher(c).Configure(Naming.UpperCase)) 33 | .WatchAssembly(typeof(DomainModel).Assembly) 34 | .Build(); 35 | 36 | var result = config.Execute(); 37 | 38 | //this will fail 39 | Assert.IsFalse(result.HasIssues); 40 | } 41 | } 42 | ``` 43 | 44 | All properties in given assembly have to be uppercase, but skip DomainModel class from checking 45 | 46 | ``` 47 | [TestFixture] 48 | public class GlobalContextTests 49 | { 50 | [Test] 51 | public void FluentConfigurationBuilder() 52 | { 53 | CodeWatcherConfig config = CodeWatcherConfig.Create() 54 | .WithWatcher(c => new PropertyNamingWatcher(c).Configure(Naming.UpperCase)) 55 | .WatchAssembly(typeof(DomainModel).Assembly) 56 | .SkipType(typeof(DomainModel)) 57 | .Build(); 58 | 59 | var result = config.Execute(); 60 | 61 | //this will fail 62 | Assert.IsFalse(result.HasIssues); 63 | } 64 | } 65 | ``` 66 | 67 | All properties in multiple assemblies have to be uppercase 68 | 69 | ``` 70 | [TestFixture] 71 | public class GlobalContextTests 72 | { 73 | [Test] 74 | public void FluentConfigurationBuilder() 75 | { 76 | CodeWatcherConfig config = CodeWatcherConfig.Create() 77 | .WithWatcher(c => new PropertyNamingWatcher(c).Configure(Naming.UpperCase)) 78 | .WatchAssembly(typeof(DomainModel).Assembly) 79 | .WatchAssembly(typeof(PersistenceLayer).Assembly) 80 | .WatchAssembly(typeof(DomainServices).Assembly) 81 | .Build(); 82 | 83 | var result = config.Execute(); 84 | 85 | //this will fail 86 | Assert.IsFalse(result.HasIssues); 87 | } 88 | } 89 | ``` 90 | 91 | All try/catch clauses in given assembly have to be handled 92 | 93 | ``` 94 | [TestFixture] 95 | public class GlobalContextTests 96 | { 97 | [Test] 98 | public void FluentConfigurationBuilder() 99 | { 100 | CodeWatcherConfig config = CodeWatcherConfig.Create() 101 | .WithWatcher(c => new ExceptionHandlingWatcher(c)) 102 | .WatchAssembly(typeof(DomainModel).Assembly) 103 | .Build(); 104 | 105 | var result = config.Execute(); 106 | 107 | //this will fail 108 | Assert.IsFalse(result.HasIssues); 109 | } 110 | } 111 | ``` 112 | 113 | All methods in assembly neet to have at most 4 parameters 114 | 115 | ``` 116 | [TestFixture] 117 | public class GlobalContextTests 118 | { 119 | [Test] 120 | public void FluentConfigurationBuilder() 121 | { 122 | CodeWatcherConfig config = CodeWatcherConfig.Create() 123 | .WithWatcher(c => new MaxMethodParametersWatcher(c).Configure(4)) 124 | .WatchAssembly(typeof(DomainModel).Assembly) 125 | .Build(); 126 | 127 | var result = config.Execute(); 128 | 129 | //this will fail 130 | Assert.IsFalse(result.HasIssues); 131 | } 132 | } 133 | ``` 134 | 135 | All methods return types must be of type IList 136 | 137 | ``` 138 | [TestFixture] 139 | public class GlobalContextTests 140 | { 141 | [Test] 142 | public void FluentConfigurationBuilder() 143 | { 144 | CodeWatcherConfig config = CodeWatcherConfig.Create() 145 | .WithWatcher(c => new MethodReturnTypeWatcher(c).Configure(typeof(IList))) 146 | .WatchAssembly(typeof(DomainModel).Assembly) 147 | .Build(); 148 | 149 | var result = config.Execute(); 150 | 151 | //this will fail 152 | Assert.IsFalse(result.HasIssues); 153 | } 154 | } 155 | ``` 156 | 157 | ## I miss a feature.... 158 | 159 | **You are very welcome to add a [pull request][1].** 160 | 161 | [1]: https://github.com/pawelklimczyk/CodeWatch/compare 162 | 163 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | pull_requests: 3 | do_not_increment_build_number: true 4 | skip_branch_with_pr: true 5 | configuration: Release 6 | platform: Any CPU 7 | assembly_info: 8 | patch: true 9 | file: '**\AssemblyInfo.*' 10 | assembly_version: '{version}' 11 | assembly_file_version: '{version}' 12 | assembly_informational_version: '{version}' 13 | environment: 14 | EnableNuGetPackageRestore: true 15 | nuget: 16 | disable_publish_on_pr: true 17 | before_build: 18 | - cmd: >- 19 | cd src 20 | 21 | nuget restore 22 | build: 23 | project: src\Gmtl.CodeWatch.sln 24 | publish_nuget: true 25 | verbosity: minimal 26 | deploy: 27 | - provider: NuGet 28 | api_key: 29 | secure: 4NFCV0P1k0CmzDxS3oEj4svkyaLF5SBctZop1acIBdHoVFNdwm482o3tLGdnXW6+ 30 | on: 31 | branch: release 32 | 33 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/CodeWatchResultTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Gmtl.CodeWatch.Tests 4 | { 5 | [TestFixture] 6 | public class CodeWatchResultTests 7 | { 8 | [Test] 9 | public void CodeWatchAggregatedException_providedAssemblyWith5ViolatedProperties_shouldReturnAggregateExcWith5SubExceptions() 10 | { 11 | var result = AssertThatWatcherThrowException(); 12 | 13 | Assert.That(result.Issues.Count, Is.EqualTo(5)); 14 | } 15 | 16 | [Test] 17 | public void CodeWatchAggregatedException_ToStringShouldContainSubExceptionDetails() 18 | { 19 | var exception = AssertThatWatcherThrowException(); 20 | 21 | StringAssert.Contains("Class1", exception.ToString()); 22 | } 23 | 24 | private CodeWatchResult AssertThatWatcherThrowException() 25 | { 26 | var watcherConfig = TestHelpers.ConfigWithLowerCasePropertyCheck 27 | .WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 28 | .Build(); 29 | 30 | var result = watcherConfig.Execute(); 31 | Assert.IsTrue(result.HasIssues); 32 | 33 | return result; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/ExceptionHandlingWatcherTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gmtl.CodeWatch.Tests.Samples.ExceptionTester; 3 | using Gmtl.CodeWatch.Watchers; 4 | using NUnit.Framework; 5 | 6 | namespace Gmtl.CodeWatch.Tests 7 | { 8 | [TestFixture] 9 | public class ExceptionHandlingWatcherTests 10 | { 11 | ExceptionHandlingWatcher sut; 12 | 13 | [SetUp] 14 | public void SetUp() 15 | { 16 | sut = new ExceptionHandlingWatcher(); 17 | } 18 | 19 | [TestCase(typeof(ExceptionTesterWithCatchAllUnhandled))] 20 | [TestCase(typeof(ExceptionTesterWithCatchAllHandledException))] 21 | [TestCase(typeof(ExceptionTesterWithParametrizedCatchExceptionV1))] 22 | [TestCase(typeof(ExceptionTesterWithParametrizedCatchExceptionV2))] 23 | [TestCase(typeof(ExceptionTesterWithHandledAndUnhandledException))] 24 | [TestCase(typeof(ExceptionTesterWithInheritedMethodBase))] 25 | [TestCase(typeof(ExceptionTesterWithPrivateMethodCatchAllUnhandled))] 26 | public void ExceptionHandlingChecker_shouldThrowWhenMethodInTypeWithoutProperExcHandlingIsPresent(Type input) 27 | { 28 | sut.WatchType(input); 29 | 30 | sut.Execute(); 31 | 32 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 33 | } 34 | 35 | [TestCase(typeof(ExceptionTesterWithHandledAndUnhandledException))] 36 | public void ExceptionHandlingChecker_shouldThrowWhenMethodInAssemlyTypesWithoutProperExcHandlingIsPresent(Type input) 37 | { 38 | sut.WatchAssembly(input.Assembly); 39 | 40 | sut.Execute(); 41 | 42 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 43 | StringAssert.Contains("Gmtl.CodeWatch.Tests.Samples.ExceptionTester.ExceptionTesterWithCatchAllHandledException", sut.Issues[0].Message); 44 | StringAssert.Contains("UnhandledException", sut.Issues[0].Message); 45 | } 46 | 47 | [TestCase(typeof(ExceptionTesterWithInheritedMethod))] 48 | public void ExceptionHandlingChecker_shouldNotThrowWhenMethodInInParentType(Type input) 49 | { 50 | sut.WatchType(input); 51 | 52 | sut.Execute(); 53 | 54 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/ExcludedAssemblyTests.cs: -------------------------------------------------------------------------------- 1 | using Gmtl.CodeWatch.Watchers; 2 | using NUnit.Framework; 3 | 4 | namespace Gmtl.CodeWatch.Tests 5 | { 6 | [TestFixture] 7 | public class ExcludedAssemblyTests 8 | { 9 | private PropertyNamingFirstLetterWatcher sut; 10 | 11 | [SetUp] 12 | public void Setup() 13 | { 14 | sut = new PropertyNamingFirstLetterWatcher(); 15 | } 16 | 17 | [Test] 18 | public void FieldNamingWatcherLowerCaseCheck_providedAssemblyWithUpperCasePropertiesToBeSkipped_ShouldPass() 19 | { 20 | sut.Configure(Naming.LowerCase); 21 | sut.SkipAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly); 22 | 23 | sut.Execute(); 24 | 25 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 26 | } 27 | 28 | [Test] 29 | public void FieldNamingWatcherLowerCaseCheck_providedAssemblyWithUpperCasePropertiesToBeWatchedAndSkipped_ShoudlPass() 30 | { 31 | var assembly = typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly; 32 | sut.Configure(Naming.LowerCase); 33 | sut.WatchAssembly(assembly); 34 | sut.SkipAssembly(assembly); 35 | 36 | sut.Execute(); 37 | 38 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 39 | } 40 | 41 | [Test] 42 | public void FieldNamingWatcherLowerCaseCheck_providedAssemblyWithUpperCasePropertiesToBeSkippedAndWatched_ShoudlFail() 43 | { 44 | var assembly = typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly; 45 | sut.Configure(Naming.LowerCase); 46 | sut.SkipAssembly(assembly); 47 | sut.WatchAssembly(assembly); 48 | 49 | sut.Execute(); 50 | 51 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/ExcludedTypeTests.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // 4 | // 5 | // ------------------------------------------------------------------------------------------------------------------- 6 | 7 | using Gmtl.CodeWatch.Tests.Samples.FieldNaming; 8 | using Gmtl.CodeWatch.Watchers; 9 | using NUnit.Framework; 10 | 11 | namespace Gmtl.CodeWatch.Tests 12 | { 13 | [TestFixture] 14 | public class ExcludedTypeTests 15 | { 16 | private FieldNamingFirstLetterWatcher sut; 17 | 18 | [SetUp] 19 | public void Setup() 20 | { 21 | sut = new FieldNamingFirstLetterWatcher(); 22 | } 23 | 24 | [Test] 25 | public void FieldNamingWatcherLowerCaseCheck_providedClassWithUpperCasePropertiesToBeSkipped_ShouldPass() 26 | { 27 | sut.Configure(Naming.LowerCase); 28 | sut.SkipType(typeof(FieldNamingPublicUppercase)); 29 | 30 | sut.Execute(); 31 | 32 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 33 | } 34 | 35 | [Test] 36 | public void FieldNamingWatcherLowerCaseCheck_providedClassWithUpperCasePropertiesToBeSkippedAndLowerCaseToBeWatchedShoudlPass() 37 | { 38 | sut.Configure(Naming.LowerCase); 39 | sut.WatchType(typeof(FieldNamingPublicLowercase)); 40 | sut.SkipType(typeof(FieldNamingPublicUppercase)); 41 | 42 | sut.Execute(); 43 | 44 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 45 | } 46 | 47 | [Test] 48 | public void FieldNamingWatcherUpperCaseCheck_providedClassWithUpperCasePropertiesToBeSkippedAndLowerCaseToBeWatchedShoudlFail() 49 | { 50 | sut.Configure(Naming.UpperCase); 51 | sut.WatchType(typeof(FieldNamingPublicLowercase)); 52 | sut.SkipType(typeof(FieldNamingPublicUppercase)); 53 | 54 | sut.Execute(); 55 | 56 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 57 | } 58 | 59 | [Test] 60 | public void FieldNamingWatcherUpperCaseCheck_providedClassWithLowerCasePropertiesToBeSkippedAndThenWatchedShoudlFail() 61 | { 62 | sut.Configure(Naming.UpperCase); 63 | sut.SkipType(typeof(FieldNamingPublicLowercase)); 64 | sut.WatchType(typeof(FieldNamingPublicLowercase)); 65 | 66 | sut.Execute(); 67 | 68 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 69 | } 70 | 71 | [Test] 72 | public void FieldNamingWatcherUpperCaseCheck_providedClassWithLowerCasePropertiesToBeWatchedAndThenSkippedShoudlPass() 73 | { 74 | sut.Configure(Naming.UpperCase); 75 | sut.WatchType(typeof(FieldNamingPublicLowercase)); 76 | sut.SkipType(typeof(FieldNamingPublicLowercase)); 77 | 78 | sut.Execute(); 79 | 80 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/FieldNamingWatcherTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gmtl.CodeWatch.Tests.Samples.FieldNaming; 3 | using Gmtl.CodeWatch.Watchers; 4 | using NUnit.Framework; 5 | 6 | namespace Gmtl.CodeWatch.Tests 7 | { 8 | [TestFixture] 9 | public class FieldNamingWatcherTests 10 | { 11 | private FieldNamingFirstLetterWatcher sut; 12 | 13 | [SetUp] 14 | public void Setup() 15 | { 16 | sut = new FieldNamingFirstLetterWatcher(); 17 | } 18 | 19 | [TestCase(typeof(FieldNamingPublicUppercase))] 20 | [TestCase(typeof(FieldNamingProtectedUppercase))] 21 | [TestCase(typeof(FieldNamingPrivateUppercase))] 22 | [TestCase(typeof(FieldNamingStaticPublicUppercase))] 23 | [TestCase(typeof(FieldNamingStaticProtectedUppercase))] 24 | [TestCase(typeof(FieldNamingStaticPrivateUppercase))] 25 | public void FieldNamingWatcherUpperCaseCheck_providedClassShouldPassWithAllUppercaseFields(Type type) 26 | { 27 | sut.Configure(Naming.UpperCase); 28 | sut.WatchType(type); 29 | 30 | sut.Execute(); 31 | 32 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 33 | } 34 | 35 | [TestCase(typeof(FieldNamingPublicLowercase))] 36 | [TestCase(typeof(FieldNamingProtectedLowercase))] 37 | [TestCase(typeof(FieldNamingPrivateLowercase))] 38 | public void FieldNamingWatcherUpperCaseCheck_providedClassShouldFailWithAllLowercaseFields(Type type) 39 | { 40 | sut.Configure(Naming.UpperCase); 41 | sut.WatchType(type); 42 | 43 | sut.Execute(); 44 | 45 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 46 | } 47 | 48 | [TestCase(typeof(FieldNamingPublicUppercase))] 49 | [TestCase(typeof(FieldNamingProtectedUppercase))] 50 | [TestCase(typeof(FieldNamingPrivateUppercase))] 51 | public void FieldNamingWatcherLowerCaseCheck_providedClassShoulFailWithAllUppercaseFields(Type type) 52 | { 53 | sut.Configure(Naming.LowerCase); 54 | sut.WatchType(type); 55 | 56 | sut.Execute(); 57 | 58 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 59 | } 60 | 61 | [TestCase(typeof(FieldNamingPublicLowercase))] 62 | [TestCase(typeof(FieldNamingProtectedLowercase))] 63 | [TestCase(typeof(FieldNamingPrivateLowercase))] 64 | public void FieldNamingWatcherLowerCaseCheck_providedClassShouldPassWithAllLowercaseFields(Type type) 65 | { 66 | sut.Configure(Naming.LowerCase); 67 | sut.WatchType(type); 68 | sut.Execute(); 69 | 70 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 71 | } 72 | 73 | [Test] 74 | public void FieldNamingWatcher_providedClassShouldOnlyCheckFieldDeclaredInIt() 75 | { 76 | sut.Configure(Naming.UpperCase); 77 | sut.WatchType(typeof(FieldNamingInheritance)); 78 | sut.Execute(); 79 | 80 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/FluentConfigurationTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Gmtl.CodeWatch.Watchers; 3 | using NUnit.Framework; 4 | 5 | namespace Gmtl.CodeWatch.Tests 6 | { 7 | [TestFixture] 8 | public class FluentConfigurationTests 9 | { 10 | [Test] 11 | public void FluentConfigurationBuilderWithUppercasePropertyWatcher_providedAssemblyWithUppercasePropertiesShouldPass() 12 | { 13 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 14 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.UpperCase)) 15 | .WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 16 | .Build(); 17 | 18 | Assert.IsFalse(watcherConfig.Execute().HasIssues); 19 | } 20 | 21 | [Test] 22 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_providedAssemblyWithUppercasePropertiesShouldFail() 23 | { 24 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 25 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 26 | .WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 27 | .Build(); 28 | 29 | Assert.IsTrue(watcherConfig.Execute().HasIssues); 30 | } 31 | 32 | [Test] 33 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_providedAssemblyWithUppercasePropertiesAndSkippingItShouldPass() 34 | { 35 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 36 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 37 | .WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 38 | .SkipAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 39 | .Build(); 40 | 41 | Assert.IsFalse(watcherConfig.Execute().HasIssues); 42 | } 43 | 44 | [Test] 45 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_skippingAssemblyWithUppercasePropertiesAndAddingItShouldFail() 46 | { 47 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 48 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 49 | .SkipAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 50 | .WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 51 | .Build(); 52 | 53 | Assert.IsTrue(watcherConfig.Execute().HasIssues); 54 | } 55 | 56 | [Test] 57 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_providedTypeWithUppercasePropertiesShouldFail() 58 | { 59 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 60 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 61 | .WatchType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 62 | .Build(); 63 | 64 | Assert.IsTrue(watcherConfig.Execute().HasIssues); 65 | } 66 | 67 | [Test] 68 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_providedTypeWithUppercasePropertiesAndSkippingItShouldPass() 69 | { 70 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 71 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 72 | .WatchType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 73 | .SkipType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 74 | .Build(); 75 | 76 | Assert.IsFalse(watcherConfig.Execute().HasIssues); 77 | } 78 | 79 | [Test] 80 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_skippingTypeWithUppercasePropertiesAndWatchingitBackShouldFail() 81 | { 82 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 83 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 84 | .SkipType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 85 | .WatchType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 86 | .Build(); 87 | 88 | Assert.IsTrue(watcherConfig.Execute().HasIssues); 89 | } 90 | 91 | [Test] 92 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_skippingAssemblyWithUppercasePropertiesAndWatchingUppercaseTypeFromThatAssemblyShouldFail() 93 | { 94 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 95 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 96 | .SkipAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 97 | .WatchType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 98 | .Build(); 99 | 100 | Assert.IsTrue(watcherConfig.Execute().HasIssues); 101 | } 102 | 103 | [Test] 104 | public void FluentConfigurationBuilderWithLowercasePropertyWatcher_watchingAssemblyWithUppercasePropertiesAndSkippingUppercaseTypeFromThatAssemblyShouldFailWithoutThatType() 105 | { 106 | CodeWatcherConfig watcherConfig = CodeWatcherConfig.Create() 107 | .WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)) 108 | .WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly) 109 | .SkipType(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1)) 110 | .Build(); 111 | 112 | var result = watcherConfig.Execute(); 113 | 114 | Assert.IsTrue(result.HasIssues); 115 | Assert.That(result.Issues.All(e => !e.Message.Contains("Class1"))); 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Gmtl.CodeWatch.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D141D3A4-AC07-4833-9B98-F02645C70676} 8 | Library 9 | Properties 10 | Gmtl.CodeWatch.Tests 11 | Gmtl.CodeWatch.Tests 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll 37 | True 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | True 67 | True 68 | FieldNaming.tt 69 | 70 | 71 | 72 | True 73 | True 74 | ManyParametersMethods.tt 75 | 76 | 77 | 78 | 79 | True 80 | True 81 | PropertyNaming.tt 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | {badd03e6-f33a-4934-baba-599d44ae1fcc} 92 | Gmtl.CodeWatch 93 | 94 | 95 | {25d8d54d-b556-4df9-a36b-b272429128bf} 96 | Gmtl.CodeWatch.TestData.AllUppercaseProperties 97 | 98 | 99 | {875619ba-6757-40cb-85c0-0e135290b1f7} 100 | Gmtl.CodeWatch.TestData.MixedPropertyNames 101 | 102 | 103 | 104 | 105 | TextTemplatingFileGenerator 106 | FieldNaming.tt.cs 107 | 108 | 109 | TextTemplatingFileGenerator 110 | ManyParametersMethods.tt.cs 111 | 112 | 113 | TextTemplatingFileGenerator 114 | PropertyNaming.tt.cs 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 126 | 127 | 128 | 129 | 136 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/MaxConstructorParametersWatcherTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gmtl.CodeWatch.Watchers; 3 | using NUnit.Framework; 4 | 5 | namespace Gmtl.CodeWatch.Tests 6 | { 7 | public class MaxConstructorParametersWatcherTests 8 | { 9 | private MaxConstructorParametersWatcher sut; 10 | 11 | [SetUp] 12 | public void Setup() 13 | { 14 | sut = new MaxConstructorParametersWatcher(); 15 | } 16 | 17 | [TestCase(typeof(ClassWithNoParametersInConstructor))] 18 | [TestCase(typeof(ClassWith1ParametersInConstructor))] 19 | [TestCase(typeof(ClassWith3ParametersInConstructor))] 20 | public void MaxConstructorParametersWatcher_providedClassShouldPassWithParametersBelow5(Type type) 21 | { 22 | sut.Configure(4); 23 | sut.WatchType(type); 24 | 25 | sut.Execute(); 26 | 27 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 28 | } 29 | 30 | [TestCase(typeof(ClassWith5ParametersInConstructor))] 31 | public void MaxConstructorParametersWatcher_providedClassShouldFailWith5Parameters(Type type) 32 | { 33 | sut.Configure(4); 34 | sut.WatchType(type); 35 | 36 | sut.Execute(); 37 | 38 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 39 | } 40 | 41 | #region test classes 42 | class ClassWithNoParametersInConstructor { } 43 | 44 | class ClassWith1ParametersInConstructor 45 | { 46 | public int A; 47 | 48 | public ClassWith1ParametersInConstructor(int a) 49 | { 50 | A = a; 51 | } 52 | } 53 | 54 | class ClassWith3ParametersInConstructor 55 | { 56 | public int A, B, C; 57 | 58 | public ClassWith3ParametersInConstructor(int a, int b, int c) 59 | { 60 | A = a; 61 | B = b; 62 | C = c; 63 | } 64 | } 65 | 66 | class ClassWith5ParametersInConstructor 67 | { 68 | public int A, B, C, D, E; 69 | 70 | public ClassWith5ParametersInConstructor(int a, int b, int c, int d, int e) 71 | { 72 | A = a; 73 | B = b; 74 | C = c; 75 | D = d; 76 | E = e; 77 | } 78 | } 79 | #endregion 80 | } 81 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/MaxMethodParametersWatcherTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gmtl.CodeWatch.Tests.Samples.ManyParametersMethods; 3 | using Gmtl.CodeWatch.Watchers; 4 | using NUnit.Framework; 5 | 6 | namespace Gmtl.CodeWatch.Tests 7 | { 8 | [TestFixture] 9 | public class MaxMethodParametersWatcherTests 10 | { 11 | private MaxMethodParametersWatcher sut; 12 | 13 | [SetUp] 14 | public void Setup() 15 | { 16 | sut = new MaxMethodParametersWatcher(); 17 | } 18 | 19 | [TestCase(typeof(ClassWithPrivateMethodHaving3Parameters))] 20 | [TestCase(typeof(ClassWithPrivateMethodHaving4Parameters))] 21 | [TestCase(typeof(ClassWithPublicMethodHaving3Parameters))] 22 | [TestCase(typeof(ClassWithPublicMethodHaving4Parameters))] 23 | [TestCase(typeof(ClassWithPublicStaticMethodHaving3Parameters))] 24 | [TestCase(typeof(ClassWithPublicStaticMethodHaving4Parameters))] 25 | public void MaxMethodParametersWatcher_providedClassShouldFailWithMethodAbove2Parameters(Type type) 26 | { 27 | sut.Configure(2); 28 | sut.WatchType(type); 29 | 30 | sut.Execute(); 31 | 32 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 33 | } 34 | 35 | [TestCase(typeof(ClassWithPrivateMethodHaving0Parameters))] 36 | [TestCase(typeof(ClassWithPrivateMethodHaving1Parameters))] 37 | [TestCase(typeof(ClassWithPrivateMethodHaving2Parameters))] 38 | [TestCase(typeof(ClassWithPublicMethodHaving0Parameters))] 39 | [TestCase(typeof(ClassWithPublicMethodHaving1Parameters))] 40 | [TestCase(typeof(ClassWithPublicMethodHaving2Parameters))] 41 | [TestCase(typeof(ClassWithPublicStaticMethodHaving0Parameters))] 42 | [TestCase(typeof(ClassWithPublicStaticMethodHaving1Parameters))] 43 | [TestCase(typeof(ClassWithPublicStaticMethodHaving2Parameters))] 44 | public void MaxMethodParametersWatcher_providedClassWithMethodBelow3ParametersShouldPass(Type type) 45 | { 46 | sut.Configure(2); 47 | sut.WatchType(type); 48 | 49 | sut.Execute(); 50 | 51 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/MethodReturnTypeWatcherTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Gmtl.CodeWatch.Tests.Samples.MethodReturnType; 4 | using Gmtl.CodeWatch.Watchers; 5 | using NUnit.Framework; 6 | 7 | namespace Gmtl.CodeWatch.Tests 8 | { 9 | [TestFixture] 10 | class MethodReturnTypeWatcherTests 11 | { 12 | MethodReturnTypeWatcher sut; 13 | 14 | [SetUp] 15 | public void Setup() 16 | { 17 | sut = new MethodReturnTypeWatcher(); 18 | } 19 | 20 | [TestCase(typeof(IList), typeof(AllMethodsReturnIListOfType))] 21 | [TestCase(typeof(List), typeof(AllMethodsReturnListOfType))] 22 | [TestCase(typeof(int), typeof(AllMethodsReturnPrimitiveTypeOfInt))] 23 | public void MethodReturnTypeWatcherWithIListCheck_TypeWithAllMethodsReturningIList_ShouldHaveZeroIssues(Type expectedType, Type classToTest) 24 | { 25 | sut.Configure(typeof(IList)); 26 | sut.WatchType(typeof(AllMethodsReturnIListOfType)); 27 | 28 | sut.Execute(); 29 | 30 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 31 | } 32 | 33 | [Test] 34 | public void MethodReturnTypeWatcherWithIListCheck_TypeWithMethodsReturningVariousTypes_ShouldHave2IssuesIssues() 35 | { 36 | sut.Configure(typeof(IList)); 37 | sut.WatchType(typeof(MethodsReturnDifferntLists)); 38 | 39 | sut.Execute(); 40 | 41 | Assert.That(sut.Issues.Count, Is.EqualTo(2)); 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gmtl.CodeWatch.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gmtl.CodeWatch.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e0499905-7ca7-4024-ae4e-6a5cb43169db")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/PropertyNamingWatcherTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gmtl.CodeWatch.Tests.Samples.PropertyNaming; 3 | using Gmtl.CodeWatch.Watchers; 4 | using NUnit.Framework; 5 | 6 | namespace Gmtl.CodeWatch.Tests 7 | { 8 | [TestFixture] 9 | public class PropertyNamingWatcherTests 10 | { 11 | private PropertyNamingFirstLetterWatcher sut; 12 | 13 | [SetUp] 14 | public void Setup() 15 | { 16 | sut = new PropertyNamingFirstLetterWatcher(); 17 | } 18 | 19 | [TestCase(typeof(PropertyNamingPublicLowercase))] 20 | [TestCase(typeof(PropertyNamingProtectedLowercase))] 21 | [TestCase(typeof(PropertyNamingPrivateLowercase))] 22 | public void PropertyNamingWatcherLowerCaseCheck_providedClassShouldPassWithAllLowercaseProperties(Type type) 23 | { 24 | sut.Configure(Naming.LowerCase); 25 | sut.WatchType(type); 26 | 27 | sut.Execute(); 28 | 29 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 30 | } 31 | 32 | [TestCase(typeof(PropertyNamingPublicLowercase))] 33 | [TestCase(typeof(PropertyNamingProtectedLowercase))] 34 | [TestCase(typeof(PropertyNamingPrivateLowercase))] 35 | public void PropertyNamingWatcherUpperCaseCheck_providedClassShouldFailWithAllLowercaseProperties(Type type) 36 | { 37 | sut.Configure(Naming.UpperCase); 38 | sut.WatchType(type); 39 | 40 | sut.Execute(); 41 | 42 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 43 | } 44 | 45 | [TestCase(typeof(PropertyNamingPublicUppercase))] 46 | [TestCase(typeof(PropertyNamingProtectedUppercase))] 47 | [TestCase(typeof(PropertyNamingPrivateUppercase))] 48 | [TestCase(typeof(PropertyNamingStaticPublicUppercase))] 49 | [TestCase(typeof(PropertyNamingStaticProtectedUppercase))] 50 | [TestCase(typeof(PropertyNamingStaticPrivateUppercase))] 51 | public void PropertyNamingWatcherLowerCaseCheck_providedClassShouldFailWithAllUppercaseProperties(Type type) 52 | { 53 | sut.Configure(Naming.LowerCase); 54 | sut.WatchType(type); 55 | 56 | sut.Execute(); 57 | 58 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 59 | } 60 | 61 | [TestCase(typeof(PropertyNamingPublicUppercase))] 62 | [TestCase(typeof(PropertyNamingProtectedUppercase))] 63 | [TestCase(typeof(PropertyNamingPrivateUppercase))] 64 | [TestCase(typeof(PropertyNamingStaticPublicUppercase))] 65 | [TestCase(typeof(PropertyNamingStaticProtectedUppercase))] 66 | [TestCase(typeof(PropertyNamingStaticPrivateUppercase))] 67 | public void PropertyNamingWatcherUpperCaseCheck_providedClassShouldPassWithAllLowercaseProperties(Type type) 68 | { 69 | sut.Configure(Naming.UpperCase); 70 | sut.WatchType(type); 71 | 72 | sut.Execute(); 73 | 74 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 75 | } 76 | 77 | [Test] 78 | public void PropertyNamingWatcher_providedClassShouldOnlyCheckFieldDeclaredInIt() 79 | { 80 | sut.Configure(Naming.UpperCase); 81 | sut.WatchType(typeof(PropertyNamingInheritance)); 82 | sut.Execute(); 83 | 84 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 85 | } 86 | 87 | [Test] 88 | public void PropertyNamingWatcherLowerCaseCheck_providedAssemblyWithMixedNamesShouldFail() 89 | { 90 | sut.Configure(Naming.LowerCase); 91 | sut.WatchAssembly(typeof(Gmtl.CodeWatch.TestData.MixedPropertyNames.Class1).Assembly); 92 | 93 | sut.Execute(); 94 | 95 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 96 | } 97 | 98 | [Test] 99 | public void PropertyNamingWatcherLowerCaseCheck_providedAssemblyWithUpperCaseNamesShouldFail() 100 | { 101 | sut.Configure(Naming.LowerCase); 102 | sut.WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly); 103 | 104 | sut.Execute(); 105 | 106 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 107 | } 108 | 109 | [Test] 110 | public void PropertyNamingWatcherUpperCaseCheck_providedAssemblyWithUpperCaseNamesShouldPass() 111 | { 112 | sut.Configure(Naming.UpperCase); 113 | sut.WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly); 114 | 115 | sut.Execute(); 116 | 117 | Assert.That(sut.Issues.Count, Is.EqualTo(0)); 118 | } 119 | 120 | [Test] 121 | public void PropertyNamingWatcher_exceptionShouldContainFailingPropertyFullName() 122 | { 123 | sut.Configure(Naming.LowerCase); 124 | sut.WatchAssembly(typeof(Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1).Assembly); 125 | 126 | sut.Execute(); 127 | 128 | Assert.That(sut.Issues.Count, Is.GreaterThan(0)); 129 | StringAssert.Contains("Gmtl.CodeWatch.TestData.AllUppercaseProperties.Class1.TestProperty", sut.Issues[0].Message); 130 | } 131 | } 132 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/.gitignore: -------------------------------------------------------------------------------- 1 | #Generation product of *.tt files 2 | *.tt.cs -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ExceptionTester/ExceptionTesterWithCatchAllHandledException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.Tests.Samples.ExceptionTester 4 | { 5 | public class ExceptionTesterWithCatchAllHandledException 6 | { 7 | public void UnhandledException() 8 | { 9 | try 10 | { 11 | ThrowException(); 12 | } 13 | catch 14 | { 15 | Console.WriteLine("Exception"); 16 | } 17 | } 18 | 19 | private void ThrowException() 20 | { 21 | throw new Exception(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ExceptionTester/ExceptionTesterWithCatchAllUnhandled.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.Tests.Samples.ExceptionTester 4 | { 5 | public class ExceptionTesterWithCatchAllUnhandled 6 | { 7 | public void UnhandledException() 8 | { 9 | try 10 | { 11 | ThrowException(); 12 | } 13 | catch 14 | { 15 | 16 | } 17 | } 18 | 19 | private void ThrowException() 20 | { 21 | throw new Exception(); 22 | } 23 | } 24 | 25 | public class ExceptionTesterWithPrivateMethodCatchAllUnhandled 26 | { 27 | public void PublicMethod() 28 | { 29 | UnhandledException(); 30 | } 31 | 32 | private void UnhandledException() 33 | { 34 | try 35 | { 36 | ThrowException(); 37 | } 38 | catch 39 | { 40 | 41 | } 42 | } 43 | 44 | private void ThrowException() 45 | { 46 | throw new Exception(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ExceptionTester/ExceptionTesterWithHandledAndUnhandledException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.Tests.Samples.ExceptionTester 4 | { 5 | public class ExceptionTesterWithHandledAndUnhandledException 6 | { 7 | public void UnhandledException() 8 | { 9 | try 10 | { 11 | ThrowException(); 12 | } 13 | catch (Exception exc) 14 | { 15 | Console.WriteLine(exc.Message); 16 | } 17 | 18 | try 19 | { 20 | ThrowException(); 21 | } 22 | catch 23 | { 24 | } 25 | } 26 | 27 | private void ThrowException() 28 | { 29 | throw new Exception(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ExceptionTester/ExceptionTesterWithInheritedMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.Tests.Samples.ExceptionTester 4 | { 5 | public class ExceptionTesterWithInheritedMethod : ExceptionTesterWithInheritedMethodBase 6 | { 7 | 8 | } 9 | 10 | public class ExceptionTesterWithInheritedMethodBase 11 | { 12 | public void UnhandledException() 13 | { 14 | try 15 | { 16 | ThrowException(); 17 | } 18 | catch 19 | { 20 | 21 | } 22 | } 23 | private void ThrowException() 24 | { 25 | throw new Exception(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ExceptionTester/ExceptionTesterWithParametrizedCatchExceptionV1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.Tests.Samples.ExceptionTester 4 | { 5 | public class ExceptionTesterWithParametrizedCatchExceptionV1 6 | { 7 | public void UnhandledException() 8 | { 9 | try 10 | { 11 | ThrowException(); 12 | } 13 | catch 14 | { 15 | 16 | } 17 | } 18 | 19 | private void ThrowException() 20 | { 21 | throw new Exception(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ExceptionTester/ExceptionTesterWithParametrizedCatchExceptionV2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.Tests.Samples.ExceptionTester 4 | { 5 | public class ExceptionTesterWithParametrizedCatchExceptionV2 6 | { 7 | public void UnhandledException() 8 | { 9 | try 10 | { 11 | ThrowException(); 12 | } 13 | catch (Exception) 14 | { 15 | } 16 | } 17 | 18 | private void ThrowException() 19 | { 20 | throw new Exception(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/FieldNaming/FieldNaming.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".tt.cs" #> 7 | using System.Collections.Generic; 8 | #pragma warning disable 169 9 | 10 | namespace Gmtl.CodeWatch.Tests.Samples.FieldNaming 11 | { 12 | <# 13 | string[] access = new []{"private","public","protected"}; 14 | for(int i = 0; i < 3; i++) 15 | { 16 | string accessUppercase = access[i].Substring(0,1).ToUpperInvariant() + access[i].Substring(1,access[i].Length-1); 17 | #> 18 | public class FieldNaming<#= accessUppercase#>Lowercase 19 | { 20 | <#= access[i] #> string field1; 21 | <#= access[i] #> object field2; 22 | <#= access[i] #> List field3; 23 | <#= access[i] #> bool field4; 24 | } 25 | 26 | public class FieldNaming<#=accessUppercase#>Uppercase 27 | { 28 | <#= access[i] #> string Field1; 29 | <#= access[i] #> object Field2; 30 | <#= access[i] #> List Field3; 31 | <#= access[i] #> bool Field4; 32 | } 33 | 34 | public class FieldNamingStatic<#=accessUppercase#>Uppercase 35 | { 36 | <#= access[i] #> static int StaticField; 37 | } 38 | 39 | <# 40 | } 41 | #> 42 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/FieldNaming/FieldNamingInheritance.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.Tests.Samples.FieldNaming 2 | { 3 | public class FieldNamingInheritance : FieldNamingInheritanceParent 4 | { 5 | public int ChildInt; 6 | protected int ChildProtectedInt; 7 | } 8 | 9 | public class FieldNamingInheritanceParent 10 | { 11 | public int ParentInt; 12 | protected int parentProtectedInt; 13 | } 14 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/ManyParametersMethods/ManyParametersMethods.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".tt.cs" #> 7 | using System; 8 | #pragma warning disable 169 9 | 10 | namespace Gmtl.CodeWatch.Tests.Samples.ManyParametersMethods 11 | { 12 | <# 13 | for(int i = 0; i < 5; i++) 14 | { 15 | #> 16 | public class ClassWithPublicMethodHaving<#=i#>Parameters 17 | { 18 | public void Method(<# for(int param = 0; paramint val<#=param#><#= param != (i-1)? ", " : "" #><#}#>) 19 | { 20 | } 21 | } 22 | 23 | public class ClassWithPrivateMethodHaving<#=i#>Parameters 24 | { 25 | private void PrivateMethod(<# for(int param = 0; paramint val<#=param#><#= param != (i-1)? ", " : "" #><#}#>) 26 | { 27 | } 28 | } 29 | 30 | public static class ClassWithPublicStaticMethodHaving<#=i#>Parameters 31 | { 32 | public static void PublicMethod(<# for(int param = 0; paramint val<#=param#><#= param != (i-1)? ", " : "" #><#}#>) 33 | { 34 | } 35 | } 36 | 37 | <# 38 | } 39 | #> 40 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/MethodReturnType/AllMethodsReturnIListOfType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace Gmtl.CodeWatch.Tests.Samples.MethodReturnType 7 | { 8 | class AllMethodsReturnIListOfType 9 | { 10 | public IList GetObjects() 11 | { 12 | return new List(); 13 | } 14 | 15 | public IList GetInts() 16 | { 17 | return new List(); 18 | } 19 | 20 | public IList GetEvenInts() 21 | { 22 | return GetInts().Where(i => i % 2 == 0).ToList(); 23 | } 24 | } 25 | 26 | class AllMethodsReturnListOfType 27 | { 28 | public List GetObjects() 29 | { 30 | return new List(); 31 | } 32 | 33 | public List GetInts() 34 | { 35 | return new List(); 36 | } 37 | 38 | public List GetEvenInts() 39 | { 40 | return GetInts().Where(i => i % 2 == 0).ToList(); 41 | } 42 | } 43 | 44 | class AllMethodsReturnPrimitiveTypeOfInt 45 | { 46 | public int GetCount1() 47 | { 48 | return 1; 49 | } 50 | 51 | public int GetCount2() 52 | { 53 | return 2; 54 | } 55 | 56 | public int GetCount3() 57 | { 58 | return 3; 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/MethodReturnType/MethodsReturnDifferntLists.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gmtl.CodeWatch.Tests.Samples.MethodReturnType 8 | { 9 | class MethodsReturnDifferntLists 10 | { 11 | public IEnumerable GetObjects() 12 | { 13 | return new List(); 14 | } 15 | 16 | public IReadOnlyList GetInts() 17 | { 18 | return new List(); 19 | } 20 | 21 | public IList GetEvenInts() 22 | { 23 | return GetInts().Where(i => i % 2 == 0).ToList(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/PropertyNaming/PropertyNaming.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ output extension="tt.cs" #> 4 | using System.Collections.Generic; 5 | #pragma warning disable 169 6 | 7 | 8 | namespace Gmtl.CodeWatch.Tests.Samples.PropertyNaming 9 | { 10 | <# 11 | string[] access = new []{"private","public","protected"}; 12 | for(int i = 0; i < 3; i++) 13 | { 14 | string accessUppercase = access[i].Substring(0,1).ToUpperInvariant() + access[i].Substring(1,access[i].Length-1); 15 | #> 16 | public class PropertyNaming<#= accessUppercase#>Lowercase 17 | { 18 | <#= access[i] #> string property1 { get; set; } 19 | <#= access[i] #> object property2 { get; set; } 20 | <#= access[i] #> List property3 { get; set; } 21 | <#= access[i] #> bool property4 { get; set; } 22 | } 23 | 24 | 25 | public class PropertyNaming<#=accessUppercase#>Uppercase 26 | { 27 | <#= access[i] #> string Property1 { get; set; } 28 | <#= access[i] #> object Property2 { get; set; } 29 | <#= access[i] #> List Property3 { get; set; } 30 | <#= access[i] #> bool Property4 { get; set; } 31 | } 32 | 33 | public class PropertyNamingStatic<#=accessUppercase#>Uppercase 34 | { 35 | <#= access[i] #> static int StaticField { get; set; } 36 | } 37 | 38 | <# 39 | } 40 | #> 41 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/Samples/PropertyNaming/PropertyNamingInheritance.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.Tests.Samples.PropertyNaming 2 | { 3 | public class PropertyNamingInheritance : PropertyNamingInheritanceParent 4 | { 5 | public int ChildInt { get; set; } 6 | protected int ChildProtectedInt { get; set; } 7 | } 8 | 9 | public class PropertyNamingInheritanceParent 10 | { 11 | public int ParentInt { get; set; } 12 | protected int parentProtectedInt { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/TestHelpers.cs: -------------------------------------------------------------------------------- 1 | using Gmtl.CodeWatch.Watchers; 2 | 3 | namespace Gmtl.CodeWatch.Tests 4 | { 5 | internal class TestHelpers 6 | { 7 | public static CodeWatcherConfig ConfigWithLowerCasePropertyCheck 8 | { 9 | get 10 | { 11 | return CodeWatcherConfig.Create().WithWatcher(c => new PropertyNamingFirstLetterWatcher(c).Configure(Naming.LowerCase)); 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch", "Gmtl.CodeWatch\Gmtl.CodeWatch.csproj", "{BADD03E6-F33A-4934-BABA-599D44AE1FCC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch.Tests", "Gmtl.CodeWatch.Tests\Gmtl.CodeWatch.Tests.csproj", "{D141D3A4-AC07-4833-9B98-F02645C70676}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestAssemblies", "TestAssemblies", "{79A7234F-D19A-4878-87DF-D10B54219DD9}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch.TestData.AllUppercaseProperties", "TestData\Gmtl.CodeWatch.TestData.AllUppercaseProperties\Gmtl.CodeWatch.TestData.AllUppercaseProperties.csproj", "{25D8D54D-B556-4DF9-A36B-B272429128BF}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch.TestData.MixedPropertyNames", "TestData\Gmtl.CodeWatch.TestData.MixedPropertyNames\Gmtl.CodeWatch.TestData.MixedPropertyNames.csproj", "{875619BA-6757-40CB-85C0-0E135290B1F7}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{AD1E5448-A5CC-4BD8-B4CE-C6FB882E8198}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {D141D3A4-AC07-4833-9B98-F02645C70676}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {D141D3A4-AC07-4833-9B98-F02645C70676}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {D141D3A4-AC07-4833-9B98-F02645C70676}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {D141D3A4-AC07-4833-9B98-F02645C70676}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {25D8D54D-B556-4DF9-A36B-B272429128BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {25D8D54D-B556-4DF9-A36B-B272429128BF}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {25D8D54D-B556-4DF9-A36B-B272429128BF}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {25D8D54D-B556-4DF9-A36B-B272429128BF}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {875619BA-6757-40CB-85C0-0E135290B1F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {875619BA-6757-40CB-85C0-0E135290B1F7}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {875619BA-6757-40CB-85C0-0E135290B1F7}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {875619BA-6757-40CB-85C0-0E135290B1F7}.Release|Any CPU.Build.0 = Release|Any CPU 40 | EndGlobalSection 41 | GlobalSection(SolutionProperties) = preSolution 42 | HideSolutionNode = FALSE 43 | EndGlobalSection 44 | GlobalSection(NestedProjects) = preSolution 45 | {D141D3A4-AC07-4833-9B98-F02645C70676} = {AD1E5448-A5CC-4BD8-B4CE-C6FB882E8198} 46 | {79A7234F-D19A-4878-87DF-D10B54219DD9} = {AD1E5448-A5CC-4BD8-B4CE-C6FB882E8198} 47 | {25D8D54D-B556-4DF9-A36B-B272429128BF} = {79A7234F-D19A-4878-87DF-D10B54219DD9} 48 | {875619BA-6757-40CB-85C0-0E135290B1F7} = {79A7234F-D19A-4878-87DF-D10B54219DD9} 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/CodeWatchException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch 4 | { 5 | /// 6 | /// Exception used to flag rules violation issue 7 | /// 8 | public class CodeWatchException : Exception 9 | { 10 | public CodeWatchException(string message) 11 | : base(message) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/CodeWatchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Gmtl.CodeWatch 6 | { 7 | public class CodeWatchResult 8 | { 9 | public CodeWatchResult(IList issues) 10 | { 11 | Issues = new List(issues); 12 | } 13 | 14 | public IReadOnlyList Issues { get; private set; } 15 | 16 | public bool HasIssues 17 | { 18 | get { return Issues.Count > 0; } 19 | } 20 | 21 | public override string ToString() 22 | { 23 | return Issues.Select(e => e.Message).Aggregate((a, b) => String.Format("{0}\r\n{1}", a, b)); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/CodeWatcherConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Gmtl.CodeWatch 6 | { 7 | public class CodeWatcherConfig 8 | { 9 | private CodeWatcherContext context; 10 | private readonly List watchers = new List(); 11 | private readonly List assembliesToCheck = new List(); 12 | private readonly List assembliesToSkip = new List(); 13 | 14 | private readonly List typesToCheck = new List(); 15 | private readonly List typesToSkip = new List(); 16 | 17 | private CodeWatcherConfig() 18 | { 19 | } 20 | 21 | public static CodeWatcherConfig Create(string confurationXml = "") 22 | { 23 | //TODO read config if exists 24 | 25 | return new CodeWatcherConfig { context = new CodeWatcherContext() }; 26 | } 27 | 28 | public CodeWatcherConfig WithWatcher(Func func) 29 | { 30 | var watcher = func(context); 31 | watchers.Add(watcher); 32 | 33 | return this; 34 | } 35 | 36 | public CodeWatcherConfig Build() 37 | { 38 | foreach (var assembly in assembliesToCheck) 39 | { 40 | foreach (var watcher in watchers) 41 | { 42 | watcher.WatchAssembly(assembly); 43 | } 44 | } 45 | 46 | foreach (var assembly in assembliesToSkip) 47 | { 48 | foreach (var watcher in watchers) 49 | { 50 | watcher.SkipAssembly(assembly); 51 | } 52 | } 53 | 54 | foreach (var type in typesToCheck) 55 | { 56 | foreach (var watcher in watchers) 57 | { 58 | watcher.WatchType(type); 59 | } 60 | } 61 | 62 | foreach (var type in typesToSkip) 63 | { 64 | foreach (var watcher in watchers) 65 | { 66 | watcher.SkipType(type); 67 | } 68 | } 69 | 70 | return this; 71 | } 72 | 73 | /// 74 | /// Executes all configured watchers againts provided assemblies and types 75 | /// 76 | public CodeWatchResult Execute() 77 | { 78 | List issues = new List(); 79 | 80 | foreach (var watcher in watchers) 81 | { 82 | watcher.Execute(); 83 | 84 | if (watcher.Issues.Count > 0) 85 | issues.AddRange(watcher.Issues); 86 | } 87 | 88 | return new CodeWatchResult(issues); 89 | } 90 | 91 | /// 92 | /// Adds assembly to list of assemblies to be checked 93 | /// 94 | /// Assembly to check 95 | /// CodeWatchConfig object 96 | public CodeWatcherConfig WatchAssembly(Assembly assembly) 97 | { 98 | assembliesToCheck.Add(assembly); 99 | 100 | if (assembliesToSkip.Contains(assembly)) 101 | assembliesToSkip.Remove(assembly); 102 | 103 | return this; 104 | } 105 | 106 | /// 107 | /// Adds assembly to list of assemblies to be skipped 108 | /// 109 | /// Assembly to skip check 110 | /// CodeWatchConfig object 111 | public CodeWatcherConfig SkipAssembly(Assembly assembly) 112 | { 113 | assembliesToSkip.Add(assembly); 114 | 115 | if (assembliesToCheck.Contains(assembly)) 116 | assembliesToCheck.Remove(assembly); 117 | 118 | return this; 119 | } 120 | 121 | public CodeWatcherConfig WatchType(Type type) 122 | { 123 | typesToCheck.Add(type); 124 | 125 | if (typesToSkip.Contains(type)) 126 | typesToSkip.Remove(type); 127 | 128 | return this; 129 | } 130 | 131 | public CodeWatcherConfig SkipType(Type type) 132 | { 133 | typesToSkip.Add(type); 134 | 135 | if (typesToCheck.Contains(type)) 136 | typesToCheck.Remove(type); 137 | 138 | return this; 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/CodeWatcherContext.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch 2 | { 3 | /// 4 | /// Placeholder for session based data 5 | /// 6 | public class CodeWatcherContext 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Gmtl.CodeWatch.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC} 8 | Library 9 | Properties 10 | Gmtl.CodeWatch 11 | Gmtl.CodeWatch 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 70 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Gmtl.CodeWatch.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Gmtl.CodeWatch 5 | $version$ 6 | Pawel Klimczyk 7 | Pawel 8 | https://github.com/pawelklimczyk/CodeWatch 9 | https://github.com/pawelklimczyk/CodeWatch 10 | false 11 | CodeWatch is used for monitoring code quality during unit/component/integration testing phase 12 | Initial version of CodeWatch 13 | Copyright Gemotial 2015-2016 14 | code-qaulity unit test tdd 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/IWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Gmtl.CodeWatch 6 | { 7 | public interface IWatcher 8 | { 9 | /// 10 | /// Add particular Type to be checked by watcher 11 | /// 12 | /// Type to be checked 13 | void WatchType(Type type); 14 | 15 | /// 16 | /// Add particular Type to be skipped by watcher 17 | /// 18 | /// Type to be skipped 19 | void SkipType(Type type); 20 | 21 | /// 22 | /// Add particular Assembly to be checked by watcher 23 | /// 24 | /// Assembly to be checked 25 | void WatchAssembly(Assembly assembly); 26 | 27 | /// 28 | /// Add particular Assembly to be skipped by watcher 29 | /// 30 | /// Assembly to be skipped 31 | void SkipAssembly(Assembly assembly); 32 | 33 | /// 34 | /// Executed watcher code check 35 | /// 36 | /// List of issues found by watcher 37 | IReadOnlyList Execute(); 38 | 39 | /// 40 | /// Contain list of issues populated with Execute() method 41 | /// 42 | IReadOnlyList Issues { get; } 43 | } 44 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/LettersMap.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Gmtl.CodeWatch 4 | { 5 | public class LettersMap 6 | { 7 | static IReadOnlyDictionary map = new Dictionary 8 | { 9 | {Naming.LowerCase, "abcdefghijklmnopqrstuwvxzy".ToCharArray()}, 10 | {Naming.UpperCase, "ABCDEFGHIJKLMNOPQRSTUWVXZY".ToCharArray()}, 11 | {Naming.Underscore, new[]{ '_'}} 12 | }; 13 | 14 | public static IReadOnlyDictionary Map { get { return map; } } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Naming.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch 2 | { 3 | /// 4 | /// Entity naming conventions 5 | /// 6 | public enum Naming 7 | { 8 | UpperCase, 9 | LowerCase, 10 | Underscore 11 | } 12 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gmtl.CodeWatch")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gmtl.CodeWatch")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0ace5a4f-0b1b-47c1-a351-32edb693423e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/AbstractWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Gmtl.CodeWatch.Watchers 6 | { 7 | public abstract class AbstractWatcher : IWatcher 8 | { 9 | protected List typesToCheck = new List(); 10 | protected List assembliesToCheck = new List(); 11 | 12 | protected List typesToSkip = new List(); 13 | protected List assembliesToSkip = new List(); 14 | 15 | protected List issuesFound = new List(); 16 | 17 | protected readonly CodeWatcherContext context; 18 | 19 | public IReadOnlyList Issues { get { return issuesFound; } } 20 | 21 | protected AbstractWatcher(CodeWatcherContext context) 22 | { 23 | this.context = context; 24 | } 25 | 26 | public void WatchType(Type type) 27 | { 28 | typesToCheck.Add(type); 29 | 30 | if (typesToSkip.Contains(type)) 31 | typesToSkip.Remove(type); 32 | } 33 | 34 | public void SkipType(Type type) 35 | { 36 | typesToSkip.Add(type); 37 | 38 | if (typesToCheck.Contains(type)) 39 | typesToCheck.Remove(type); 40 | } 41 | 42 | public void WatchAssembly(Assembly assembly) 43 | { 44 | assembliesToCheck.Add(assembly); 45 | 46 | if (assembliesToSkip.Contains(assembly)) 47 | assembliesToSkip.Remove(assembly); 48 | } 49 | 50 | public void SkipAssembly(Assembly assembly) 51 | { 52 | assembliesToSkip.Add(assembly); 53 | 54 | if (assembliesToCheck.Contains(assembly)) 55 | assembliesToCheck.Remove(assembly); 56 | } 57 | 58 | public IReadOnlyList Execute() 59 | { 60 | foreach (Type type in typesToCheck) 61 | { 62 | CheckType(type); 63 | } 64 | 65 | foreach (var assembly in assembliesToCheck) 66 | { 67 | foreach (var type in assembly.GetTypes()) 68 | { 69 | if (typesToSkip.Contains(type)) continue; 70 | 71 | CheckType(type); 72 | } 73 | } 74 | 75 | return Issues; 76 | } 77 | 78 | protected void AddIssue(CodeWatchException exception) 79 | { 80 | issuesFound.Add(exception); 81 | } 82 | 83 | protected abstract void CheckType(Type type); 84 | } 85 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/ExceptionHandlingWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Gmtl.CodeWatch.Watchers 6 | { 7 | public class ExceptionHandlingWatcher : AbstractWatcher 8 | { 9 | private static Type objType = typeof(Object); 10 | 11 | public ExceptionHandlingWatcher(CodeWatcherContext context = null) : base(context) { } 12 | 13 | protected override void CheckType(Type type) 14 | { 15 | foreach (var methodInfo in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) 16 | { 17 | var methodBody = methodInfo.GetMethodBody(); 18 | if (methodBody == null) continue; 19 | 20 | foreach (var excHandCauses in methodBody.ExceptionHandlingClauses.Where(c => c.Flags != ExceptionHandlingClauseOptions.Finally)) 21 | { 22 | if (excHandCauses.CatchType == objType) 23 | { 24 | AddIssue(new CodeWatchException(String.Format("Method {0} in type {1} has catch-all exception handler", methodInfo.Name, type.FullName))); 25 | } 26 | else if (excHandCauses.HandlerLength <= 6) 27 | { 28 | AddIssue(new CodeWatchException(String.Format("Method {0} in type {1} does not handle exception in catch clause", methodInfo.Name, type.FullName))); 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/FieldNamingFirstLetterWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | 6 | namespace Gmtl.CodeWatch.Watchers 7 | { 8 | public class FieldNamingFirstLetterWatcher : AbstractWatcher 9 | { 10 | private Naming namingConvention = Naming.UpperCase; 11 | 12 | public FieldNamingFirstLetterWatcher(CodeWatcherContext context = null) : base(context) { } 13 | 14 | protected override void CheckType(Type type) 15 | { 16 | foreach (FieldInfo pi in type.GetFields(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) 17 | { 18 | if (pi.GetCustomAttributes(typeof(CompilerGeneratedAttribute), true).Length > 0) continue; 19 | 20 | char firstLetter = pi.Name[0]; 21 | 22 | if (!LettersMap.Map[namingConvention].Contains(firstLetter)) 23 | { 24 | AddIssue(new CodeWatchException(String.Format("Field {0} does not meet FirstLetter standards", pi.Name))); 25 | } 26 | } 27 | } 28 | 29 | public AbstractWatcher Configure(Naming convention) 30 | { 31 | namingConvention = convention; 32 | 33 | return this; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/MaxConstructorParametersWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Gmtl.CodeWatch.Watchers 5 | { 6 | public class MaxConstructorParametersWatcher : AbstractWatcher 7 | { 8 | private int maxParametersInConstroctur = 4; 9 | 10 | private readonly BindingFlags searchFlags = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static; 11 | 12 | public MaxConstructorParametersWatcher(CodeWatcherContext context = null) : base(context) { } 13 | 14 | protected override void CheckType(Type type) 15 | { 16 | 17 | foreach (ConstructorInfo constructorInfo in type.GetConstructors(searchFlags)) 18 | { 19 | var parameter = constructorInfo.GetParameters(); 20 | 21 | if (parameter.Length > maxParametersInConstroctur) 22 | { 23 | AddIssue(new CodeWatchException(String.Format("Constructor {0}.{1} does not meet MaxConstructorParametersWatcher standards. Parameter limit for constructor is {2}", type.FullName, constructorInfo.Name, maxParametersInConstroctur))); 24 | } 25 | } 26 | } 27 | 28 | /// 29 | /// Confugure how much maximum parameters can constructor 30 | /// 31 | /// max number of parameters 32 | /// watcher 33 | public AbstractWatcher Configure(int newMaxParametersCount) 34 | { 35 | maxParametersInConstroctur = newMaxParametersCount; 36 | 37 | return this; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/MaxMethodParametersWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Gmtl.CodeWatch.Watchers 5 | { 6 | /// 7 | /// Checks if Type contains methods with parameters count more than given. 8 | /// 9 | public class MaxMethodParametersWatcher : AbstractWatcher 10 | { 11 | private int maxParametersInMethod = 10; 12 | 13 | private readonly BindingFlags searchFlags = BindingFlags.Public | BindingFlags.DeclaredOnly | 14 | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; 15 | 16 | public MaxMethodParametersWatcher(CodeWatcherContext context = null) : base(context) { } 17 | 18 | protected override void CheckType(Type type) 19 | { 20 | foreach (MethodInfo methodInfo in type.GetMethods(searchFlags)) 21 | { 22 | var parameter = methodInfo.GetParameters(); 23 | 24 | if (parameter.Length > maxParametersInMethod) 25 | { 26 | AddIssue(new CodeWatchException(String.Format("Method {0}.{1} does not meet MaxMethodParametersWatcher standards. Parameter limit for method is {2}", type.FullName, methodInfo.Name, maxParametersInMethod))); 27 | } 28 | } 29 | } 30 | 31 | /// 32 | /// Confugure how much maximum parameters can method have 33 | /// 34 | /// max number of parameters 35 | /// watcher 36 | public AbstractWatcher Configure(int newMaxParametersCount) 37 | { 38 | maxParametersInMethod = newMaxParametersCount; 39 | 40 | return this; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/MethodReturnTypeWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Gmtl.CodeWatch.Watchers 5 | { 6 | public class MethodReturnTypeWatcher : AbstractWatcher 7 | { 8 | private Type expectedType; 9 | 10 | public MethodReturnTypeWatcher(CodeWatcherContext context = null) : base(context) { } 11 | 12 | public void Configure(Type type) 13 | { 14 | expectedType = type; 15 | } 16 | 17 | protected override void CheckType(Type type) 18 | { 19 | foreach (MethodInfo mi in type.GetMethods(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static)) 20 | { 21 | Type actualType = mi.ReturnType; 22 | 23 | if (actualType.IsGenericType) 24 | { 25 | bool genericTypeMatch = actualType.GetGenericTypeDefinition() == expectedType.GetGenericTypeDefinition(); 26 | 27 | bool genericParametersMatch = actualType.GenericTypeArguments.Length == expectedType.GenericTypeArguments.Length; 28 | 29 | if (genericParametersMatch) 30 | { 31 | for (int i = 0; i < actualType.GenericTypeArguments.Length; i++) 32 | { 33 | genericParametersMatch &= ((actualType.GenericTypeArguments[i] == expectedType.GenericTypeArguments[i]) | actualType.GenericTypeArguments[i].IsSubclassOf(expectedType.GenericTypeArguments[i])); 34 | } 35 | } 36 | 37 | if (!(genericTypeMatch & genericParametersMatch)) 38 | { 39 | AddIssue(new CodeWatchException(String.Format("Method {0} does not meet MethodReturnType standards. Expected:{1} Actual:{2}", mi.Name, expectedType, mi.ReturnType))); 40 | } 41 | 42 | continue; 43 | } 44 | 45 | if (expectedType != mi.ReturnType) 46 | { 47 | AddIssue(new CodeWatchException(String.Format("Method {0} does not meet MethodReturnType standards. Expected:{1} Actual:{2}", mi.Name, expectedType, mi.ReturnType))); 48 | } 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/PropertyNamingFirstLetterWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Gmtl.CodeWatch.Watchers 6 | { 7 | public class PropertyNamingFirstLetterWatcher : AbstractWatcher 8 | { 9 | private Naming namingConvention = Naming.UpperCase; 10 | 11 | public PropertyNamingFirstLetterWatcher(CodeWatcherContext context = null) : base(context) { } 12 | 13 | protected override void CheckType(Type type) 14 | { 15 | foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) 16 | { 17 | char firstLetter = pi.Name[0]; 18 | 19 | if (!LettersMap.Map[namingConvention].Contains(firstLetter)) 20 | { 21 | AddIssue(new CodeWatchException(String.Format("Property {0}.{1} does not meet PropertyNamingFirstLetter standards", type.FullName, pi.Name))); 22 | } 23 | } 24 | } 25 | 26 | public AbstractWatcher Configure(Naming convention) 27 | { 28 | namingConvention = convention; 29 | 30 | return this; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Gmtl.CodeWatch/Watchers/TextBasedWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace Gmtl.CodeWatch.Watchers 5 | { 6 | class TextBasedWatcher : AbstractWatcher 7 | { 8 | private Regex matcher; 9 | 10 | public TextBasedWatcher(CodeWatcherContext context) : base(context) 11 | { 12 | } 13 | 14 | protected override void CheckType(Type type) 15 | { 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/GlobalContextTests.cs: -------------------------------------------------------------------------------- 1 | using Gmtl.CodeWatch.Watchers; 2 | using NUnit.Framework; 3 | 4 | namespace Gmtl.CodeWatch.SampleProject.Tests 5 | { 6 | public class GlobalContextTests 7 | { 8 | [Test] 9 | public void FluentConfigurationBuilderWillFailForFields() 10 | { 11 | CodeWatcherConfig config = CodeWatcherConfig.Create() 12 | .WithWatcher(c => new FieldNamingFirstLetterWatcher(c).Configure(Naming.UpperCase)) 13 | .WatchAssembly(typeof(DomainModel).Assembly) 14 | .Build(); 15 | 16 | //execute configuration 17 | var result = config.Execute(); 18 | 19 | //This will fail 20 | Assert.True(result.HasIssues); 21 | } 22 | 23 | [Test] 24 | public void FluentConfigurationBuilderWillPassForFields() 25 | { 26 | CodeWatcherConfig config = CodeWatcherConfig.Create() 27 | .WithWatcher(c => new FieldNamingFirstLetterWatcher(c).Configure(Naming.Underscore)) 28 | .WatchAssembly(typeof(DomainModel).Assembly) 29 | .Build(); 30 | 31 | //execute configuration 32 | var result = config.Execute(); 33 | 34 | //This will pass 35 | Assert.False(result.HasIssues); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/Gmtl.CodeWatch.SampleProject.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D9F9C766-D923-4B67-B75A-FEE461C2FD88} 8 | Library 9 | Properties 10 | Gmtl.CodeWatch.SampleProject.Tests 11 | Gmtl.CodeWatch.SampleProject.Tests 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll 35 | True 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {badd03e6-f33a-4934-baba-599d44ae1fcc} 55 | Gmtl.CodeWatch 56 | 57 | 58 | {b6f2f0cc-d3e2-4d18-8ca4-04d269b14cc2} 59 | Gmtl.CodeWatch.SampleProject 60 | 61 | 62 | 63 | 64 | 65 | 66 | 73 | -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gmtl.CodeWatch.SampleProject.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gmtl.CodeWatch.SampleProject.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4b51f40c-fda5-45d8-a743-e1c12332b04e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/WatchAllTryCatchBlocksHandleException.cs: -------------------------------------------------------------------------------- 1 | using Gmtl.CodeWatch.Watchers; 2 | using NUnit.Framework; 3 | 4 | namespace Gmtl.CodeWatch.SampleProject.Tests 5 | { 6 | [TestFixture] 7 | public class WatchAllTryCatchBlocksHandleException 8 | { 9 | [Test] 10 | public void AllTryCatchBlocksInAssembyMustBeHandledWillFail() 11 | { 12 | ExceptionHandlingWatcher exceptionHandlingWatcher = new ExceptionHandlingWatcher(); 13 | exceptionHandlingWatcher.WatchAssembly(typeof(DomainModel).Assembly); 14 | 15 | exceptionHandlingWatcher.Execute(); 16 | 17 | //ruleViolations contain all methods that not handle exceptions properly 18 | var ruleViolations = exceptionHandlingWatcher.Issues; 19 | 20 | //Failure! 21 | Assert.That(ruleViolations.Count, Is.GreaterThan(0)); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/WatchFieldNamesInAssemblies.cs: -------------------------------------------------------------------------------- 1 | using Gmtl.CodeWatch.Watchers; 2 | using NUnit.Framework; 3 | 4 | namespace Gmtl.CodeWatch.SampleProject.Tests 5 | { 6 | [TestFixture] 7 | public class WatchFieldNamesInAssemblies 8 | { 9 | [Test] 10 | public void AllPropertiesInAssemblyMustStartWithUppercaseWillFail() 11 | { 12 | FieldNamingFirstLetterWatcher fieldNamingWatcher = new FieldNamingFirstLetterWatcher(); 13 | fieldNamingWatcher.Configure(Naming.UpperCase); 14 | fieldNamingWatcher.WatchAssembly(typeof(DomainModel).Assembly); 15 | 16 | fieldNamingWatcher.Execute(); 17 | 18 | //ruleViolations contain all fields that are not uppercase 19 | var ruleViolations = fieldNamingWatcher.Issues; 20 | 21 | //Failure! 22 | Assert.That(ruleViolations.Count,Is.GreaterThan(0)); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/WatchPropertyNamesInAssemblies.cs: -------------------------------------------------------------------------------- 1 | using Gmtl.CodeWatch.Watchers; 2 | using NUnit.Framework; 3 | 4 | namespace Gmtl.CodeWatch.SampleProject.Tests 5 | { 6 | [TestFixture] 7 | public class WatchPropertyNamesInAssemblies 8 | { 9 | [Test] 10 | public void AllPropertiesInAssemblyMustStartWithUppercaseWillFail() 11 | { 12 | PropertyNamingFirstLetterWatcher propertyNamingWatcher = new PropertyNamingFirstLetterWatcher(); 13 | propertyNamingWatcher.Configure(Naming.UpperCase); 14 | propertyNamingWatcher.WatchAssembly(typeof(DomainModel).Assembly); 15 | 16 | propertyNamingWatcher.Execute(); 17 | 18 | //ruleViolations contain all properties that are not uppercase 19 | var ruleViolations = propertyNamingWatcher.Issues; 20 | 21 | //Failure! 22 | Assert.That(ruleViolations.Count, Is.GreaterThan(0)); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch.SampleProject", "Gmtl.CodeWatch.SampleProject\Gmtl.CodeWatch.SampleProject.csproj", "{B6F2F0CC-D3E2-4D18-8CA4-04D269B14CC2}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch.SampleProject.Tests", "Gmtl.CodeWatch.SampleProject.Tests\Gmtl.CodeWatch.SampleProject.Tests.csproj", "{D9F9C766-D923-4B67-B75A-FEE461C2FD88}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gmtl.CodeWatch", "..\Gmtl.CodeWatch\Gmtl.CodeWatch.csproj", "{BADD03E6-F33A-4934-BABA-599D44AE1FCC}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B6F2F0CC-D3E2-4D18-8CA4-04D269B14CC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {B6F2F0CC-D3E2-4D18-8CA4-04D269B14CC2}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {B6F2F0CC-D3E2-4D18-8CA4-04D269B14CC2}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {B6F2F0CC-D3E2-4D18-8CA4-04D269B14CC2}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {D9F9C766-D923-4B67-B75A-FEE461C2FD88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {D9F9C766-D923-4B67-B75A-FEE461C2FD88}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {D9F9C766-D923-4B67-B75A-FEE461C2FD88}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {D9F9C766-D923-4B67-B75A-FEE461C2FD88}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {BADD03E6-F33A-4934-BABA-599D44AE1FCC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject/DomainModel.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.SampleProject 2 | { 3 | public class DomainModel 4 | { 5 | private bool _Flag; 6 | 7 | public int DomainProperty { get; set; } 8 | public int anotherDomainProperty { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject/DomainService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Gmtl.CodeWatch.SampleProject 4 | { 5 | public class DomainService 6 | { 7 | public List GetElements() 8 | { 9 | try 10 | { 11 | //simulate returing data from database 12 | return new List(); 13 | } 14 | catch 15 | { 16 | return new List(); 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject/Gmtl.CodeWatch.SampleProject.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B6F2F0CC-D3E2-4D18-8CA4-04D269B14CC2} 8 | Library 9 | Properties 10 | Gmtl.CodeWatch.SampleProject 11 | Gmtl.CodeWatch.SampleProject 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /src/SampleProject/Gmtl.CodeWatch.SampleProject/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gmtl.CodeWatch.SampleProject")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gmtl.CodeWatch.SampleProject")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("dff0f424-74b4-465a-94d7-21cb724cf050")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.AllUppercaseProperties/Class1.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.TestData.AllUppercaseProperties 2 | { 3 | public class Class1 4 | { 5 | public int TestProperty1 { get; set; } 6 | public int TestProperty2 { get; set; } 7 | public int TestProperty3 { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.AllUppercaseProperties/Class2.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.TestData.AllUppercaseProperties 2 | { 3 | public class Class2 4 | { 5 | public string StringProperty { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.AllUppercaseProperties/Class3.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.TestData.AllUppercaseProperties 2 | { 3 | public class Class3 4 | { 5 | public int PropertySample { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.AllUppercaseProperties/Gmtl.CodeWatch.TestData.AllUppercaseProperties.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {25D8D54D-B556-4DF9-A36B-B272429128BF} 8 | Library 9 | Properties 10 | Gmtl.CodeWatch.TestData.AllUppercaseProperties 11 | Gmtl.CodeWatch.TestData.AllUppercaseProperties 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.AllUppercaseProperties/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gmtl.CodeWatch.TestData.AllUppercaseProperties")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gmtl.CodeWatch.TestData.AllUppercaseProperties")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("842bbb5b-f090-4ca8-8c8b-215f7b2be66b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.MixedPropertyNames/Class1.cs: -------------------------------------------------------------------------------- 1 | namespace Gmtl.CodeWatch.TestData.MixedPropertyNames 2 | { 3 | public class Class1 4 | { 5 | public int myProperty { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.MixedPropertyNames/Class2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.TestData.MixedPropertyNames 4 | { 5 | public class Class2 6 | { 7 | public String StringProperty { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.MixedPropertyNames/Class3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gmtl.CodeWatch.TestData.MixedPropertyNames 4 | { 5 | public class Class3 6 | { 7 | public String StringProperty { get; set; } 8 | public int myProperty { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.MixedPropertyNames/Gmtl.CodeWatch.TestData.MixedPropertyNames.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {875619BA-6757-40CB-85C0-0E135290B1F7} 8 | Library 9 | Properties 10 | Gmtl.CodeWatch.TestData.MixedPropertyNames 11 | Gmtl.CodeWatch.TestData.MixedPropertyNames 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | -------------------------------------------------------------------------------- /src/TestData/Gmtl.CodeWatch.TestData.MixedPropertyNames/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gmtl.CodeWatch.TestData.MixedPropertyNames")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gmtl.CodeWatch.TestData.MixedPropertyNames")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bf9b4915-bde4-4c1d-bbfe-9bf76a52a50d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | --------------------------------------------------------------------------------