Skip to content

Commit 55d4028

Browse files
Merge pull request #156 from bugsnag/release/3.0.1
Release 3.0.1
2 parents f7b7aeb + 4c4ed0f commit 55d4028

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
## 3.0.1 (2022-03-24)
5+
6+
### Bug fixes
7+
8+
* Ensure RemoveProjectRoots works for assemblies that are run on a OS that differs from their build OS.
9+
| [sgtfrankieboy](https://github.com/sgtfrankieboy)
10+
| [#154](https://github.com/bugsnag/bugsnag-dotnet/pull/154)
11+
412
## 3.0.0 (2022-01-31)
513

614
### Breaking Changes

Directory.build.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<Project>
22
<PropertyGroup>
33
<OutputPath>$(BaseOutputPath)</OutputPath>
4-
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Bugsnag.snk</AssemblyOriginatorKeyFile>
5-
<SignAssembly>true</SignAssembly>
64
</PropertyGroup>
75
</Project>

src/Bugsnag/Middleware.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,26 @@ public static class InternalMiddleware
3939
{
4040
var projectRoots = report.Configuration.ProjectRoots.Select(prefix => {
4141
// if the file prefix is missing a final directory seperator then we should
42-
// add one first
43-
if (prefix[prefix.Length - 1] != System.IO.Path.DirectorySeparatorChar)
42+
// add one first.
43+
var finalChar = prefix[prefix.Length - 1];
44+
45+
// Check if a prefix is a Unix-based path, if it is we add a `/`.
46+
// Otherwise its a Windows-based path and we add `\` instead, if necessary.
47+
if (prefix[0] == '/')
48+
{
49+
if (finalChar != '/')
50+
{
51+
prefix = $"{prefix}/";
52+
}
53+
}
54+
else if (finalChar != '\\')
4455
{
45-
prefix = $"{prefix}{System.IO.Path.DirectorySeparatorChar}";
56+
// DirectorySeparatorChar is not being used because its `/` on Unix
57+
// systems and will break the check when running assemblies build
58+
// on Windows but are run on Linux.
59+
prefix = $"{prefix}\\";
4660
}
61+
4762
return prefix;
4863
}).ToArray();
4964

src/Directory.build.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<Project>
2-
3-
<Import Project="..\Directory.Build.props"/>
4-
52
<PropertyGroup>
63
<Authors>snmaynard kattrali martin308</Authors>
74
<Version></Version>
@@ -15,5 +12,7 @@
1512
<LangVersion>7.1</LangVersion>
1613
<WarningsAsErrors />
1714
<NoWarn>1591</NoWarn>
15+
<AssemblyOriginatorKeyFile>$(MSBuildStartupDirectory)\Bugsnag.snk</AssemblyOriginatorKeyFile>
16+
<SignAssembly>true</SignAssembly>
1817
</PropertyGroup>
1918
</Project>

tests/Bugsnag.Tests/MiddlewareTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ public void ProjectRootStrippingTests(string[] projectRoots, string fileName, st
5858

5959
public static IEnumerable<object[]> ProjectRootTestData()
6060
{
61+
// Tests for Windows-based paths
6162
yield return new object[] { new string[] { @"C:\app" }, @"C:\app\Class.cs", "Class.cs" };
6263
yield return new object[] { new string[] { @"C:\app\" }, @"C:\app\Class.cs", "Class.cs" };
64+
65+
// Tests for Unix-based paths
66+
yield return new object[] { new string[] { @"/app" }, @"/app/Class.cs", "Class.cs" };
67+
yield return new object[] { new string[] { @"/app/" }, @"/app/Class.cs", "Class.cs" };
68+
6369
// for this scenario we should only strip the file path once, here we
6470
// have a setup where the first prefix will then also cause the second
6571
// prefix to match. This should only strip the first prefix

tests/Directory.build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project>
2+
<Import Project="..\Directory.Build.props"/>
23
<PropertyGroup>
34
<SignAssembly>false</SignAssembly>
45
</PropertyGroup>

0 commit comments

Comments
 (0)