Skip to content

Commit

Permalink
Disable PathMap for debug to fix symbols mapping (#670)
Browse files Browse the repository at this point in the history
* Disable PathMap for debug to fix symbols mapping

Enabling it for debug prevent debugger from loading symbols

* Update Directory.Build.props

* Fix tests

---------

Co-authored-by: Keith Cully <[email protected]>
Co-authored-by: artempushkin <[email protected]>
Co-authored-by: Neil <[email protected]>
  • Loading branch information
4 people authored Jun 17, 2024
1 parent f097608 commit 9341682
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
<!-- Optional: Include the PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<SourceRootLocation>$(MSBuildThisFileDirectory)</SourceRootLocation>
<!-- Maps paths injected by CallerFilePath attribute to be related and independent from repository location on hard drive -->
<PathMap>$(MSBuildThisFileDirectory)=/</PathMap>
<!--
Maps paths injected by CallerFilePath attribute to be related and independent from repository location on hard drive to keep automatic log tags independent of the build location.
Doing this prevents debugger from finding symbols, so setting is disabled for debug builds.
-->
<PathMap Condition="'$(Configuration)' != 'Debug'">$(MSBuildThisFileDirectory)=/</PathMap>
</PropertyGroup>
</Project>
15 changes: 12 additions & 3 deletions tests/Abstractions.UnitTests/TagTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using Microsoft.Extensions.Logging;
Expand All @@ -22,8 +22,17 @@ public void Create_HasProperValues()


string relativePath = "/tests/Abstractions.UnitTests/" + nameof(TagTests) + ".cs"; //This value should be change in case of changing file path or name
Assert.AreEqual(tag1.Name, relativePath, "tag1 Name should point to current file");
Assert.AreEqual(tag2.Name, relativePath, "tag2 Name should point to current file");
AssertTagNames(relativePath, tag1.Name, "tag1 Name should point to current file");
AssertTagNames(relativePath, tag2.Name, "tag2 Name should point to current file");
}

private static void AssertTagNames(string expectedTag, string? actualTag, string message)
{
#if DEBUG
StringAssert.EndsWith(actualTag?.Replace('\\','/'), expectedTag, message);
#else
Assert.AreEqual(expectedTag, actualTag, message);
#endif
}

[DataTestMethod]
Expand Down

0 comments on commit 9341682

Please sign in to comment.