Skip to content

Commit 5bc18ec

Browse files
authored
Integration test for assembly resolver for mvc.razor (#1502)
1 parent 95b5cdf commit 5bc18ec

File tree

12 files changed

+159
-7
lines changed

12 files changed

+159
-7
lines changed

Documentation/Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
9+
### Fixed
10+
-Fix problem with coverage for .net5 WPF application [#1221](https://github.com/coverlet-coverage/coverlet/issues/1221) by https://github.com/lg2de
11+
-Fix unable to instrument module for Microsoft.AspNetCore.Mvc.Razor [#1459](https://github.com/coverlet-coverage/coverlet/issues/1459) by https://github.com/lg2de
12+
713
## Release date 2023-05-21
814
### Packages
915
coverlet.msbuild 6.0.0

coverlet.sln

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio Version 17
43
VisualStudioVersion = 17.2.32208.508
@@ -54,17 +53,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{9A8B19D4
5453
test\Directory.Build.targets = test\Directory.Build.targets
5554
EndProjectSection
5655
EndProject
57-
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}"
56+
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "coverlet.tests.projectsample.vbmynamespace", "test\coverlet.tests.projectsample.vbmynamespace\coverlet.tests.projectsample.vbmynamespace.vbproj", "{C9B7DC34-3E04-4F20-AED4-73791AF8020D}"
5857
EndProject
5958
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "coverlet.tests.projectsample.fsharp", "test\coverlet.tests.projectsample.fsharp\coverlet.tests.projectsample.fsharp.fsproj", "{1CBF6966-2A67-4D2C-8598-D174B83072F4}"
6059
EndProject
6160
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.tests.projectsample.netframework", "test\coverlet.tests.projectsample.netframework\coverlet.tests.projectsample.netframework.csproj", "{E69D68C9-78ED-4076-A14B-D07295A4B2A5}"
6261
EndProject
63-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.aspnet6", "test\coverlet.tests.projectsample.aspnet6\coverlet.tests.projectsample.aspnet6.csproj", "{1C3CA3F8-DF8C-433F-8A56-69102D2BBDF6}"
62+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.tests.projectsample.aspnet6", "test\coverlet.tests.projectsample.aspnet6\coverlet.tests.projectsample.aspnet6.csproj", "{1C3CA3F8-DF8C-433F-8A56-69102D2BBDF6}"
6463
EndProject
65-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.aspnet6.tests", "test\coverlet.tests.projectsample.aspnet6.tests\coverlet.tests.projectsample.aspnet6.tests.csproj", "{8EC065A4-7700-45E6-8B90-0182E3649DEA}"
64+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.tests.projectsample.aspnet6.tests", "test\coverlet.tests.projectsample.aspnet6.tests\coverlet.tests.projectsample.aspnet6.tests.csproj", "{8EC065A4-7700-45E6-8B90-0182E3649DEA}"
6665
EndProject
67-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.wpf6", "test\coverlet.tests.projectsample.wpf6\coverlet.tests.projectsample.wpf6.csproj", "{988A5FF0-4326-4F5B-9F05-CB165543A555}"
66+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.tests.projectsample.wpf6", "test\coverlet.tests.projectsample.wpf6\coverlet.tests.projectsample.wpf6.csproj", "{988A5FF0-4326-4F5B-9F05-CB165543A555}"
67+
EndProject
68+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.aspmvcrazor", "test\coverlet.tests.projectsample.aspmvcrazor\coverlet.tests.projectsample.aspmvcrazor.csproj", "{6ACF69B1-C01F-44A4-8F8E-2501884238D4}"
69+
EndProject
70+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coverlet.tests.projectsample.aspmvcrazor.tests", "test\coverlet.tests.projectsample.aspmvcrazor.tests\coverlet.tests.projectsample.aspmvcrazor.tests.csproj", "{F508CCDD-5BC8-4AB6-97B3-D37498813C41}"
71+
ProjectSection(ProjectDependencies) = postProject
72+
{31084026-D563-4B91-BE71-174C4270CCF4} = {31084026-D563-4B91-BE71-174C4270CCF4}
73+
{6ACF69B1-C01F-44A4-8F8E-2501884238D4} = {6ACF69B1-C01F-44A4-8F8E-2501884238D4}
74+
EndProjectSection
6875
EndProject
6976
Global
7077
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -152,6 +159,14 @@ Global
152159
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Debug|Any CPU.Build.0 = Debug|Any CPU
153160
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Release|Any CPU.ActiveCfg = Release|Any CPU
154161
{988A5FF0-4326-4F5B-9F05-CB165543A555}.Release|Any CPU.Build.0 = Release|Any CPU
162+
{6ACF69B1-C01F-44A4-8F8E-2501884238D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
163+
{6ACF69B1-C01F-44A4-8F8E-2501884238D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
164+
{6ACF69B1-C01F-44A4-8F8E-2501884238D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
165+
{6ACF69B1-C01F-44A4-8F8E-2501884238D4}.Release|Any CPU.Build.0 = Release|Any CPU
166+
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
167+
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Debug|Any CPU.Build.0 = Debug|Any CPU
168+
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Release|Any CPU.ActiveCfg = Release|Any CPU
169+
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Release|Any CPU.Build.0 = Release|Any CPU
155170
EndGlobalSection
156171
GlobalSection(SolutionProperties) = preSolution
157172
HideSolutionNode = FALSE
@@ -172,12 +187,14 @@ Global
172187
{5FF404AD-7C0B-465A-A1E9-558CDC642B0C} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
173188
{F8199E19-FA9A-4559-9101-CAD7028121B4} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
174189
{9A8B19D4-4A24-4217-AEFE-159B68F029A1} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
190+
{C9B7DC34-3E04-4F20-AED4-73791AF8020D} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
175191
{1CBF6966-2A67-4D2C-8598-D174B83072F4} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
176192
{E69D68C9-78ED-4076-A14B-D07295A4B2A5} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
177-
{C9B7DC34-3E04-4F20-AED4-73791AF8020D} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
178193
{1C3CA3F8-DF8C-433F-8A56-69102D2BBDF6} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
179194
{8EC065A4-7700-45E6-8B90-0182E3649DEA} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
180195
{988A5FF0-4326-4F5B-9F05-CB165543A555} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
196+
{6ACF69B1-C01F-44A4-8F8E-2501884238D4} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
197+
{F508CCDD-5BC8-4AB6-97B3-D37498813C41} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
181198
EndGlobalSection
182199
GlobalSection(ExtensibilityGlobals) = postSolution
183200
SolutionGuid = {9CA57C02-97B0-4C38-A027-EA61E8741F10}

src/coverlet.core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Toni Solarin-Sodara
1+
// Copyright (c) Toni Solarin-Sodara
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System.Reflection;
@@ -15,6 +15,7 @@
1515
[assembly: InternalsVisibleTo("coverlet.integration.tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010001d24efbe9cbc2dc49b7a3d2ae34ca37cfb69b4f450acd768a22ce5cd021c8a38ae7dc68b2809a1ac606ad531b578f192a5690b2986990cbda4dd84ec65a3a4c1c36f6d7bb18f08592b93091535eaee2f0c8e48763ed7f190db2008e1f9e0facd5c0df5aaab74febd3430e09a428a72e5e6b88357f92d78e47512d46ebdc3cbb")]
1616
[assembly: InternalsVisibleTo("coverlet.tests.projectsample.aspnet6.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100757cf9291d78a82e5bb58a827a3c46c2f959318327ad30d1b52e918321ffbd847fb21565b8576d2a3a24562a93e86c77a298b564a0f1b98f63d7a1441a3a8bcc206da3ed09d5dacc76e122a109a9d3ac608e21a054d667a2bae98510a1f0f653c0e6f58f42b4b3934f6012f5ec4a09b3dfd3e14d437ede1424bdb722aead64ad")]
1717
[assembly: InternalsVisibleTo("coverlet.tests.projectsample.wpf6.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100757cf9291d78a82e5bb58a827a3c46c2f959318327ad30d1b52e918321ffbd847fb21565b8576d2a3a24562a93e86c77a298b564a0f1b98f63d7a1441a3a8bcc206da3ed09d5dacc76e122a109a9d3ac608e21a054d667a2bae98510a1f0f653c0e6f58f42b4b3934f6012f5ec4a09b3dfd3e14d437ede1424bdb722aead64ad")]
18+
[assembly: InternalsVisibleTo("coverlet.tests.projectsample.aspmvcrazor.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100757cf9291d78a82e5bb58a827a3c46c2f959318327ad30d1b52e918321ffbd847fb21565b8576d2a3a24562a93e86c77a298b564a0f1b98f63d7a1441a3a8bcc206da3ed09d5dacc76e122a109a9d3ac608e21a054d667a2bae98510a1f0f653c0e6f58f42b4b3934f6012f5ec4a09b3dfd3e14d437ede1424bdb722aead64ad")]
1819

1920
// Needed to mock internal type https://github.com/Moq/moq4/wiki/Quickstart#advanced-features
2021
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Toni Solarin-Sodara
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Reflection;
5+
6+
[assembly: AssemblyKeyFile("coverlet.tests.projectsample.aspmvcrazor.tests.snk")]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Toni Solarin-Sodara
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Reflection;
7+
using Coverlet.Core.Abstractions;
8+
using Coverlet.Core.Instrumentation;
9+
using Microsoft.Extensions.DependencyModel;
10+
using Moq;
11+
using Xunit;
12+
13+
namespace coverlet.tests.projectsample.aspmvcrazor.tests
14+
{
15+
public class ResolverTests
16+
{
17+
[Fact]
18+
public void TestInstrument_NetCoreSharedFrameworkResolver()
19+
{
20+
Assembly assembly = GetType().Assembly;
21+
var mockLogger = new Mock<ILogger>();
22+
var resolver = new NetCoreSharedFrameworkResolver(assembly.Location, mockLogger.Object);
23+
var compilationLibrary = new CompilationLibrary(
24+
"package",
25+
"Microsoft.AspNetCore.Mvc.Razor",
26+
"0.0.0.0",
27+
"sha512-not-relevant",
28+
Enumerable.Empty<string>(),
29+
Enumerable.Empty<Dependency>(),
30+
true);
31+
32+
var assemblies = new List<string>();
33+
Assert.True(resolver.TryResolveAssemblyPaths(compilationLibrary, assemblies),
34+
"sample assembly shall be resolved");
35+
Assert.NotEmpty(assemblies);
36+
}
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<IsPackable>false</IsPackable>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
10+
<PackageReference Include="Moq" />
11+
<PackageReference Include="xunit" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\src\coverlet.core\coverlet.core.csproj" />
16+
<ProjectReference Include="..\coverlet.tests.projectsample.aspmvcrazor\coverlet.tests.projectsample.aspmvcrazor.csproj" />
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Toni Solarin-Sodara
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using Microsoft.AspNetCore.Mvc.Razor;
5+
6+
namespace coverlet.tests.projectsample.aspmvcrazor
7+
{
8+
public static class Class
9+
{
10+
public static IMvcBuilder AddLocalization(this IMvcBuilder mvcBuilder,
11+
LanguageViewLocationExpanderFormat viewLocationExpanderFormat = LanguageViewLocationExpanderFormat.Suffix)
12+
{
13+
return mvcBuilder;
14+
}
15+
}
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Toni Solarin-Sodara
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
var builder = WebApplication.CreateBuilder(args);
5+
6+
// Add services to the container.
7+
builder.Services.AddRazorPages();
8+
9+
var app = builder.Build();
10+
11+
// Configure the HTTP request pipeline.
12+
if (!app.Environment.IsDevelopment())
13+
{
14+
app.UseExceptionHandler("/Error");
15+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
16+
app.UseHsts();
17+
}
18+
19+
app.UseHttpsRedirection();
20+
app.UseStaticFiles();
21+
22+
app.UseRouting();
23+
24+
app.UseAuthorization();
25+
26+
app.MapRazorPages();
27+
28+
app.Run();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)