From 27956744978a982436d6e7a0a87747250b7417fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Tue, 26 Jan 2021 23:48:31 +0100 Subject: [PATCH 01/13] exclude type that doesn't have a source file --- src/coverlet.core/Instrumentation/Instrumenter.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/coverlet.core/Instrumentation/Instrumenter.cs b/src/coverlet.core/Instrumentation/Instrumenter.cs index 575be13be..2204eb450 100644 --- a/src/coverlet.core/Instrumentation/Instrumenter.cs +++ b/src/coverlet.core/Instrumentation/Instrumenter.cs @@ -511,6 +511,9 @@ private void InstrumentType(TypeDefinition type) private void InstrumentMethod(MethodDefinition method) { var sourceFile = method.DebugInformation.SequencePoints.Select(s => _sourceRootTranslator.ResolveFilePath(s.Document.Url)).FirstOrDefault(); + + if (string.IsNullOrEmpty(sourceFile)) return; + if (!string.IsNullOrEmpty(sourceFile) && _excludedFilesHelper.Exclude(sourceFile)) { if (!(_excludedSourceFiles ??= new List()).Contains(sourceFile)) From 8c18caa6d7a4945eb05d373d0ab80cd64c1a69a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Thu, 28 Jan 2021 02:06:34 +0100 Subject: [PATCH 02/13] adapted test --- test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs index 005c995fb..e51733b17 100644 --- a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs +++ b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs @@ -597,7 +597,7 @@ public int SampleMethod() } else { - Assert.NotEmpty(result.Documents); + Assert.Empty(result.Documents); } } From 883fc1515c90afa60562727f3f670d253fe935fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Fri, 5 Feb 2021 07:33:47 +0100 Subject: [PATCH 03/13] added log and test --- coverlet.sln | 7 ++ .../Instrumentation/Instrumenter.cs | 2 + .../Instrumentation/InstrumenterTests.cs | 16 +++ .../coverlet.core.tests.csproj | 1 + .../My Project/Application.Designer.vb | 13 ++ .../My Project/Application.myapp | 10 ++ .../My Project/AssemblyInfo.vb | 35 ++++++ .../My Project/Resources.Designer.vb | 62 ++++++++++ .../My Project/Resources.resx | 117 ++++++++++++++++++ .../My Project/Settings.Designer.vb | 73 +++++++++++ .../My Project/Settings.settings | 7 ++ .../SampleVbClass.vb | 5 + ...t.tests.projectsample.vbmynamespace.vbproj | 107 ++++++++++++++++ 13 files changed, 455 insertions(+) create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/SampleVbClass.vb create mode 100644 test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj diff --git a/coverlet.sln b/coverlet.sln index 17d712674..c6b53ce6c 100644 --- a/coverlet.sln +++ b/coverlet.sln @@ -53,6 +53,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{9A8B19D4 test\Directory.Build.targets = test\Directory.Build.targets EndProjectSection EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "coverlet.tests.projectsample.vbmynamespace", "test\coverlet.tests.projectsample.vbmynamespace\coverlet.tests.projectsample.vbmynamespace.vbproj", "{C9B7DC34-3E04-4F20-AED4-73791AF8020D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -115,6 +117,10 @@ Global {F8199E19-FA9A-4559-9101-CAD7028121B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8199E19-FA9A-4559-9101-CAD7028121B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8199E19-FA9A-4559-9101-CAD7028121B4}.Release|Any CPU.Build.0 = Release|Any CPU + {C9B7DC34-3E04-4F20-AED4-73791AF8020D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9B7DC34-3E04-4F20-AED4-73791AF8020D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9B7DC34-3E04-4F20-AED4-73791AF8020D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9B7DC34-3E04-4F20-AED4-73791AF8020D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -135,6 +141,7 @@ Global {5FF404AD-7C0B-465A-A1E9-558CDC642B0C} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134} {F8199E19-FA9A-4559-9101-CAD7028121B4} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134} {9A8B19D4-4A24-4217-AEFE-159B68F029A1} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134} + {C9B7DC34-3E04-4F20-AED4-73791AF8020D} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9CA57C02-97B0-4C38-A027-EA61E8741F10} diff --git a/src/coverlet.core/Instrumentation/Instrumenter.cs b/src/coverlet.core/Instrumentation/Instrumenter.cs index 2204eb450..01c6f2738 100644 --- a/src/coverlet.core/Instrumentation/Instrumenter.cs +++ b/src/coverlet.core/Instrumentation/Instrumenter.cs @@ -510,6 +510,8 @@ private void InstrumentType(TypeDefinition type) private void InstrumentMethod(MethodDefinition method) { + _logger.LogInformation($"Instrumenting method '{method.FullName}' in module '{_module}'."); + var sourceFile = method.DebugInformation.SequencePoints.Select(s => _sourceRootTranslator.ResolveFilePath(s.Document.Url)).FirstOrDefault(); if (string.IsNullOrEmpty(sourceFile)) return; diff --git a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs index e51733b17..2306cf417 100644 --- a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs +++ b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs @@ -783,6 +783,22 @@ public void TestReachabilityHelper() instrumenterTest.Directory.Delete(true); } + [Fact] + public void Instrumenter_MethodsWithoutReferenceToSource_AreSkipped() + { + var loggerMock = new Mock(); + string sample = Directory.GetFiles(Directory.GetCurrentDirectory(), "coverlet.tests.projectsample.vbmynamespace.dll").First(); + InstrumentationHelper instrumentationHelper = + new InstrumentationHelper(new ProcessExitHandler(), new RetryHelper(), new FileSystem(), new Mock().Object, + new SourceRootTranslator(sample, new Mock().Object, new FileSystem())); + + var instrumenter = new Instrumenter(sample, "_coverlet_tests_projectsample_vbmynamespace", Array.Empty(), Array.Empty(), Array.Empty(), + Array.Empty(), Array.Empty(), false, false, loggerMock.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(sample, loggerMock.Object, new FileSystem()), new CecilSymbolHelper()); + + var result = instrumenter.Instrument(); + + Assert.False(result.Documents.ContainsKey(string.Empty)); + } } } diff --git a/test/coverlet.core.tests/coverlet.core.tests.csproj b/test/coverlet.core.tests/coverlet.core.tests.csproj index cb97da613..aab42781c 100644 --- a/test/coverlet.core.tests/coverlet.core.tests.csproj +++ b/test/coverlet.core.tests/coverlet.core.tests.csproj @@ -26,6 +26,7 @@ + diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb new file mode 100644 index 000000000..88dd01c78 --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp new file mode 100644 index 000000000..758895def --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb new file mode 100644 index 000000000..2c823c472 --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + +' +' diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb new file mode 100644 index 000000000..fa40ef6c8 --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("coverlet.tests.projectsample.vbmynamespace.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb new file mode 100644 index 000000000..0cf9cf12e --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.coverlet.tests.projectsample.vbmynamespace.My.MySettings + Get + Return Global.coverlet.tests.projectsample.vbmynamespace.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings new file mode 100644 index 000000000..85b890b3c --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/coverlet.tests.projectsample.vbmynamespace/SampleVbClass.vb b/test/coverlet.tests.projectsample.vbmynamespace/SampleVbClass.vb new file mode 100644 index 000000000..bce7be710 --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/SampleVbClass.vb @@ -0,0 +1,5 @@ +Public Class SampleVbClass + Sub SampleSub() + Return + End Sub +End Class diff --git a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj new file mode 100644 index 000000000..8a5d5da43 --- /dev/null +++ b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj @@ -0,0 +1,107 @@ + + + + + Debug + AnyCPU + {C9B7DC34-3E04-4F20-AED4-73791AF8020D} + Library + coverlet.tests.projectsample.vbmynamespace + coverlet.tests.projectsample.vbmynamespace + 512 + Windows + v4.7.2 + true + + + true + full + true + true + bin\Debug\ + coverlet.tests.projectsample.vbmynamespace.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + coverlet.tests.projectsample.vbmynamespace.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + latest + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file From 02c92d66a8882c44d7c820f9c3cf5d3f0a8392b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Fri, 5 Feb 2021 08:04:52 +0100 Subject: [PATCH 04/13] added nuget.build.tasks.pack --- .../coverlet.tests.projectsample.vbmynamespace.vbproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj index 8a5d5da43..fdfadda30 100644 --- a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj +++ b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj @@ -103,5 +103,12 @@ Settings.Designer.vb + + + 5.8.1 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + \ No newline at end of file From 8088969b2aa2548addaf00c69f82bb62cb3d9a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Fri, 5 Feb 2021 11:42:54 +0100 Subject: [PATCH 05/13] test --- src/coverlet.core/Instrumentation/Instrumenter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coverlet.core/Instrumentation/Instrumenter.cs b/src/coverlet.core/Instrumentation/Instrumenter.cs index 01c6f2738..b49b45f1a 100644 --- a/src/coverlet.core/Instrumentation/Instrumenter.cs +++ b/src/coverlet.core/Instrumentation/Instrumenter.cs @@ -510,7 +510,7 @@ private void InstrumentType(TypeDefinition type) private void InstrumentMethod(MethodDefinition method) { - _logger.LogInformation($"Instrumenting method '{method.FullName}' in module '{_module}'."); + //_logger.LogInformation($"Instrumenting method '{method.FullName}' in module '{_module}'."); var sourceFile = method.DebugInformation.SequencePoints.Select(s => _sourceRootTranslator.ResolveFilePath(s.Document.Url)).FirstOrDefault(); From 812aba8bb1427549f106466f6be8a34e64084724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Fri, 5 Feb 2021 13:54:21 +0100 Subject: [PATCH 06/13] fixed test --- .../Instrumentation/InstrumenterTests.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs index 2306cf417..d850fb542 100644 --- a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs +++ b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs @@ -788,17 +788,30 @@ public void Instrumenter_MethodsWithoutReferenceToSource_AreSkipped() { var loggerMock = new Mock(); - string sample = Directory.GetFiles(Directory.GetCurrentDirectory(), "coverlet.tests.projectsample.vbmynamespace.dll").First(); - InstrumentationHelper instrumentationHelper = + // Default case + string module = Directory.GetFiles(Directory.GetCurrentDirectory(), "coverlet.tests.projectsample.vbmynamespace.dll").First(); + string pdb = Path.Combine(Path.GetDirectoryName(module), Path.GetFileNameWithoutExtension(module) + ".pdb"); + + var directory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + File.Copy(module, Path.Combine(directory.FullName, Path.GetFileName(module)), true); + File.Copy(pdb, Path.Combine(directory.FullName, Path.GetFileName(pdb)), true); + + InstrumentationHelper instrumentationHelper = new InstrumentationHelper(new ProcessExitHandler(), new RetryHelper(), new FileSystem(), new Mock().Object, - new SourceRootTranslator(sample, new Mock().Object, new FileSystem())); + new SourceRootTranslator(module, new Mock().Object, new FileSystem())); - var instrumenter = new Instrumenter(sample, "_coverlet_tests_projectsample_vbmynamespace", Array.Empty(), Array.Empty(), Array.Empty(), - Array.Empty(), Array.Empty(), false, false, loggerMock.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(sample, loggerMock.Object, new FileSystem()), new CecilSymbolHelper()); - var result = instrumenter.Instrument(); + Instrumenter instrumenter = new Instrumenter(Path.Combine(directory.FullName, Path.GetFileName(module)), "_coverlet_tests_projectsample_vbmynamespace", Array.Empty(), Array.Empty(), Array.Empty(), + Array.Empty(), Array.Empty(), false, false, loggerMock.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(Path.Combine(directory.FullName, Path.GetFileName(module)), loggerMock.Object, new FileSystem()), new CecilSymbolHelper()); + instrumentationHelper.BackupOriginalModule(Path.Combine(directory.FullName, Path.GetFileName(module)), "_coverlet_tests_projectsample_vbmynamespace"); + + var result = instrumenter.Instrument(); + Assert.False(result.Documents.ContainsKey(string.Empty)); + + directory.Delete(true); } } } From ff030c97b890042369fae31fa9562a5cd8f2ec34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Fri, 5 Feb 2021 13:54:30 +0100 Subject: [PATCH 07/13] nit --- test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs index d850fb542..0b5983aa9 100644 --- a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs +++ b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs @@ -788,7 +788,6 @@ public void Instrumenter_MethodsWithoutReferenceToSource_AreSkipped() { var loggerMock = new Mock(); - // Default case string module = Directory.GetFiles(Directory.GetCurrentDirectory(), "coverlet.tests.projectsample.vbmynamespace.dll").First(); string pdb = Path.Combine(Path.GetDirectoryName(module), Path.GetFileNameWithoutExtension(module) + ".pdb"); From 410d8d2bd6d60d9f2dca555150ece8b8c4d0b524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Sat, 6 Feb 2021 02:10:56 +0100 Subject: [PATCH 08/13] added reference assemblies --- .../coverlet.tests.projectsample.vbmynamespace.vbproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj index fdfadda30..77d4b3538 100644 --- a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj +++ b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj @@ -104,6 +104,11 @@ + + 1.0.0 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + 5.8.1 runtime; build; native; contentfiles; analyzers; buildtransitive From a004beae1b5bd7eb498b3607d6b88b590f562a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Wed, 18 Jan 2023 00:26:27 +0100 Subject: [PATCH 09/13] fix test --- .../Instrumentation/InstrumenterTests.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs index 2a7424404..33b98c5ef 100644 --- a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs +++ b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs @@ -816,22 +816,23 @@ public void Instrumenter_MethodsWithoutReferenceToSource_AreSkipped() string module = Directory.GetFiles(Directory.GetCurrentDirectory(), "coverlet.tests.projectsample.vbmynamespace.dll").First(); string pdb = Path.Combine(Path.GetDirectoryName(module), Path.GetFileNameWithoutExtension(module) + ".pdb"); - var directory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + DirectoryInfo directory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); File.Copy(module, Path.Combine(directory.FullName, Path.GetFileName(module)), true); File.Copy(pdb, Path.Combine(directory.FullName, Path.GetFileName(pdb)), true); - InstrumentationHelper instrumentationHelper = + var instrumentationHelper = new InstrumentationHelper(new ProcessExitHandler(), new RetryHelper(), new FileSystem(), new Mock().Object, new SourceRootTranslator(module, new Mock().Object, new FileSystem())); + CoverageParameters parameters = new(); - Instrumenter instrumenter = new Instrumenter(Path.Combine(directory.FullName, Path.GetFileName(module)), "_coverlet_tests_projectsample_vbmynamespace", Array.Empty(), Array.Empty(), Array.Empty(), - Array.Empty(), Array.Empty(), false, false, loggerMock.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(Path.Combine(directory.FullName, Path.GetFileName(module)), loggerMock.Object, new FileSystem()), new CecilSymbolHelper()); + var instrumenter = new Instrumenter(Path.Combine(directory.FullName, Path.GetFileName(module)), "_coverlet_tests_projectsample_vbmynamespace", parameters, + loggerMock.Object, instrumentationHelper, new FileSystem(), new SourceRootTranslator(Path.Combine(directory.FullName, Path.GetFileName(module)), loggerMock.Object, new FileSystem()), new CecilSymbolHelper()); instrumentationHelper.BackupOriginalModule(Path.Combine(directory.FullName, Path.GetFileName(module)), "_coverlet_tests_projectsample_vbmynamespace"); - var result = instrumenter.Instrument(); + InstrumenterResult result = instrumenter.Instrument(); Assert.False(result.Documents.ContainsKey(string.Empty)); From 61975391f1b51554c469388548198c59c4b81780 Mon Sep 17 00:00:00 2001 From: David Mueller IWS Date: Sun, 22 Jan 2023 00:02:08 +0100 Subject: [PATCH 10/13] update test project to use new sdk style project file --- .../My Project/Application.Designer.vb | 13 -- .../My Project/Application.myapp | 10 -- .../My Project/AssemblyInfo.vb | 35 ------ .../My Project/Resources.Designer.vb | 62 --------- .../My Project/Resources.resx | 117 ----------------- .../My Project/Settings.Designer.vb | 73 ----------- .../My Project/Settings.settings | 7 -- ...t.tests.projectsample.vbmynamespace.vbproj | 118 +----------------- 8 files changed, 4 insertions(+), 431 deletions(-) delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb delete mode 100644 test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c78..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp deleted file mode 100644 index 758895def..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb deleted file mode 100644 index 2c823c472..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' General Information about an assembly is controlled through the following -' set of attributes. Change these attribute values to modify the information -' associated with an assembly. - -' Review the values of the assembly attributes - - - - - - - - - - -'The following GUID is for the ID of the typelib if this project is exposed to COM - - -' Version information for an assembly consists of the following four values: -' -' Major Version -' Minor Version -' Build Number -' Revision -' -' You can specify all the values or you can default the Build and Revision Numbers -' by using the '*' as shown below: -' - -' -' diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb deleted file mode 100644 index fa40ef6c8..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("coverlet.tests.projectsample.vbmynamespace.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb deleted file mode 100644 index 0cf9cf12e..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.coverlet.tests.projectsample.vbmynamespace.My.MySettings - Get - Return Global.coverlet.tests.projectsample.vbmynamespace.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings b/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings deleted file mode 100644 index 85b890b3c..000000000 --- a/test/coverlet.tests.projectsample.vbmynamespace/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj index 77d4b3538..3b626df5a 100644 --- a/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj +++ b/test/coverlet.tests.projectsample.vbmynamespace/coverlet.tests.projectsample.vbmynamespace.vbproj @@ -1,119 +1,9 @@ - - - + + - Debug - AnyCPU - {C9B7DC34-3E04-4F20-AED4-73791AF8020D} - Library coverlet.tests.projectsample.vbmynamespace - coverlet.tests.projectsample.vbmynamespace - 512 - Windows - v4.7.2 - true - - - true - full - true - true - bin\Debug\ - coverlet.tests.projectsample.vbmynamespace.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - pdbonly - false - true - true - bin\Release\ - coverlet.tests.projectsample.vbmynamespace.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - + net48 latest - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - 1.0.0 - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - 5.8.1 - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - + \ No newline at end of file From d16002baf137e968a8fb06786e7b444f7b3434e6 Mon Sep 17 00:00:00 2001 From: David Mueller IWS Date: Sun, 22 Jan 2023 00:19:06 +0100 Subject: [PATCH 11/13] update changelog --- Documentation/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index ad6acfc0a..69d71cdd3 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Fixed +-Empty path exception in visual basic projects [#775](https://github.com/coverlet-coverage/coverlet/issues/775) -Allign published nuget package version to github release version [#1413](https://github.com/coverlet-coverage/coverlet/issues/1413) -Sync nuget and github release versions [#1122](https://github.com/coverlet-coverage/coverlet/issues/1122) From cf608b3b325c73db4b9de37c745568f8ca1a9657 Mon Sep 17 00:00:00 2001 From: David Mueller IWS Date: Tue, 24 Jan 2023 01:19:44 +0100 Subject: [PATCH 12/13] adapted unit test --- .../Instrumentation/InstrumenterTests.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs index 33b98c5ef..39d5d06d3 100644 --- a/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs +++ b/test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs @@ -615,15 +615,8 @@ public int SampleMethod() var instrumenter = new Instrumenter(excludedbyattributeDll, "_xunit_excludedbyattribute", parametes, loggerMock.Object, instrumentationHelper, partialMockFileSystem.Object, new SourceRootTranslator(loggerMock.Object, new FileSystem()), new CecilSymbolHelper()); InstrumenterResult result = instrumenter.Instrument(); - if (expectedExcludes) - { - Assert.Empty(result.Documents); - loggerMock.Verify(l => l.LogVerbose(It.IsAny())); - } - else - { - Assert.Empty(result.Documents); - } + Assert.Empty(result.Documents); + if (expectedExcludes) { loggerMock.Verify(l => l.LogVerbose(It.IsAny())); } } [Fact] From a6a19fe616328119aee0394822831b6dff74b4df Mon Sep 17 00:00:00 2001 From: David Mueller IWS Date: Tue, 24 Jan 2023 01:36:42 +0100 Subject: [PATCH 13/13] nit --- test/coverlet.core.tests/coverlet.core.tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/coverlet.core.tests/coverlet.core.tests.csproj b/test/coverlet.core.tests/coverlet.core.tests.csproj index 76552cb00..f54c85f67 100644 --- a/test/coverlet.core.tests/coverlet.core.tests.csproj +++ b/test/coverlet.core.tests/coverlet.core.tests.csproj @@ -29,7 +29,7 @@ - +