Skip to content

Commit

Permalink
Merge pull request #154 from sgtfrankieboy/master
Browse files Browse the repository at this point in the history
Ensure RemoveProjectRoots works for assemblies that are run on a OS that differs from their build OS.
  • Loading branch information
yousif-bugsnag committed Feb 28, 2022
2 parents 8a8bf41 + f199ee1 commit 8ede8a9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Changelog
=========

## 3.0.0 (2022-01-31)

### Breaking Changes

The `Bugnsag.dll`, `Bugsnag.AspNet.dll`, `Bugsnag.AspNet.Mvc.dll` and `Bugsnag.AspNet.WebApi.dll` assemblies are now strong-name signed. The strong name key file `Bugsnag.snk` has been added to the repository. `Bugsnag.AspNet.Core.dll` remains unchanged. See the upgrade guide for more details.

### Bug fixes

* Strong name sign assemblies
| [yousif-bugsnag](https://github.com/yousif-bugsnag)
| [#151](https://github.com/bugsnag/bugsnag-dotnet/pull/151)

* Ensure breadcrumbs are returned in the correct order
| [yousif-bugsnag](https://github.com/yousif-bugsnag)
| [#150](https://github.com/bugsnag/bugsnag-dotnet/pull/150)

## 2.2.3 (2021-09-06)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ If you are targeting .NET Framework, v3.0.0 contains binary breaking changes due
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
```

.NET Core and .NET 5/6 do not recognise strong names so there is no action required if targetting one of those.
## 1.x to 2.x

*Our .NET notifier has gone through some major improvements, and there are some changes you'll need to make to get onto the new version.*
Expand Down
21 changes: 18 additions & 3 deletions src/Bugsnag/Middleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,26 @@ public static class InternalMiddleware
{
var projectRoots = report.Configuration.ProjectRoots.Select(prefix => {
// if the file prefix is missing a final directory seperator then we should
// add one first
if (prefix[prefix.Length - 1] != System.IO.Path.DirectorySeparatorChar)
// add one first.
var finalChar = prefix[prefix.Length - 1];
// Check if a prefix is a Unix-based path, if it is we add a `/`.
// Otherwise its a Windows-based path and we add `\` instead, if necessary.
if (prefix[0] == '/')
{
if (finalChar != '/')
{
prefix = $"{prefix}/";
}
}
else if (finalChar != '\\')
{
prefix = $"{prefix}{System.IO.Path.DirectorySeparatorChar}";
// DirectorySeparatorChar is not being used because its `/` on Unix
// systems and will break the check when running assemblies build
// on Windows but are run on Linux.
prefix = $"{prefix}\\";
}
return prefix;
}).ToArray();
Expand Down
6 changes: 6 additions & 0 deletions tests/Bugsnag.Tests/MiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ public void ProjectRootStrippingTests(string[] projectRoots, string fileName, st

public static IEnumerable<object[]> ProjectRootTestData()
{
// Tests for Windows-based paths
yield return new object[] { new string[] { @"C:\app" }, @"C:\app\Class.cs", "Class.cs" };
yield return new object[] { new string[] { @"C:\app\" }, @"C:\app\Class.cs", "Class.cs" };

// Tests for Unix-based paths
yield return new object[] { new string[] { @"/app" }, @"/app/Class.cs", "Class.cs" };
yield return new object[] { new string[] { @"/app/" }, @"/app/Class.cs", "Class.cs" };

// for this scenario we should only strip the file path once, here we
// have a setup where the first prefix will then also cause the second
// prefix to match. This should only strip the first prefix
Expand Down

0 comments on commit 8ede8a9

Please sign in to comment.