-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change FileName to be relative to project root #1739
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7c43c6b
add AttributeReader
SimonCropp b17cef2
Merge branch 'main' into AttributeReader
SimonCropp cf02e18
Update CHANGELOG.md
SimonCropp 7d1408d
.
SimonCropp d84a50b
.
SimonCropp b9281cf
.
SimonCropp d993e8f
Merge branch 'main' into AttributeReader
SimonCropp d0d5219
.
SimonCropp 69b42d6
.
SimonCropp 5cf4907
Fix failing test
mattjohnsonpint 52b445f
Update src/Sentry/AttributeReader.cs
mattjohnsonpint 34783ec
Merge branch 'main' into AttributeReader
SimonCropp 5939c2d
Merge branch 'main' into AttributeReader
SimonCropp 297f31d
Update SentryStackTraceFactoryTests.cs
SimonCropp ff10b96
Merge branch 'main' into AttributeReader
SimonCropp 59ab8db
.
SimonCropp 6f62a5a
Update Sentry.props
SimonCropp b09f13c
nits
mattjohnsonpint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Sentry | ||
{ | ||
internal static class AttributeReader | ||
{ | ||
public static bool TryGetProjectDirectory(Assembly assembly, out string? projectDirectory) | ||
{ | ||
projectDirectory = assembly.GetCustomAttributes<AssemblyMetadataAttribute>() | ||
.FirstOrDefault(x => x.Key == "Sentry.ProjectDirectory") | ||
?.Value; | ||
return projectDirectory != null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<SentryAttributesFile>Sentry.Attributes$(MSBuildProjectExtension.Replace('proj', ''))</SentryAttributesFile> | ||
</PropertyGroup> | ||
<Target Name="WriteSentryAttributes" | ||
Condition="$(Language) == 'VB' or $(Language) == 'C#' or $(Language) == 'F#'" | ||
BeforeTargets="BeforeCompile;CoreCompile" | ||
Inputs="$(MSBuildAllProjects)" | ||
Outputs="$(IntermediateOutputPath)$(SentryAttributesFile)"> | ||
<PropertyGroup> | ||
<SentryAttributesFilePath>$(IntermediateOutputPath)$(SentryAttributesFile)</SentryAttributesFilePath> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<SentryAttributes Include="System.Reflection.AssemblyMetadata"> | ||
<_Parameter1>Sentry.ProjectDirectory</_Parameter1> | ||
<_Parameter2>$(ProjectDir)</_Parameter2> | ||
</SentryAttributes> | ||
<SentryAttributes Include="System.Reflection.AssemblyMetadata" | ||
Condition="'$(SolutionDir)' != '' And '$(SolutionDir)' != '*Undefined*'"> | ||
<_Parameter1>Sentry.SolutionDirectory</_Parameter1> | ||
<_Parameter2>$(SolutionDir)</_Parameter2> | ||
</SentryAttributes> | ||
<!-- Ensure not part of Compile, as a workaround for https://github.com/dotnet/sdk/issues/114 --> | ||
<Compile Remove="$(SentryAttributesFilePath)" /> | ||
</ItemGroup> | ||
<WriteCodeFragment AssemblyAttributes="@(SentryAttributes)" | ||
Language="$(Language)" | ||
OutputFile="$(SentryAttributesFilePath)"> | ||
<Output Condition="$(Language) != 'F#'" | ||
TaskParameter="OutputFile" | ||
ItemName="Compile"/> | ||
<Output Condition="$(Language) == 'F#'" | ||
TaskParameter="OutputFile" | ||
ItemName="CompileBefore"/> | ||
<Output TaskParameter="OutputFile" | ||
ItemName="FileWrites" /> | ||
</WriteCodeFragment> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Sentry.Tests; | ||
|
||
public class AttributeReaderTests | ||
{ | ||
[Fact] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, this should run on iOS AOT'ed so we would see how it behaves there. Assuming the tests are running there following #1703 |
||
public void Simple() | ||
{ | ||
var assembly = typeof(AttributeReaderTests).Assembly; | ||
Assert.True(AttributeReader.TryGetProjectDirectory(assembly, out var projectDirectory)); | ||
Assert.NotNull(projectDirectory); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...try.Tests/Internals/SentryStackTraceFactoryTests.MethodGeneric_mode=Enhanced.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
FileName: {ProjectDirectory}Internals/SentryStackTraceFactoryTests.cs, | ||
FileName: Internals/SentryStackTraceFactoryTests.cs, | ||
Function: void SentryStackTraceFactoryTests.GenericMethodThatThrows<T>(T value), | ||
InApp: true | ||
} |
2 changes: 1 addition & 1 deletion
2
...try.Tests/Internals/SentryStackTraceFactoryTests.MethodGeneric_mode=Original.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,6 @@ | |
</Compile> | ||
</ItemGroup> | ||
|
||
<Import Project="..\..\src\Sentry\buildTransitive\Sentry.props" /> | ||
|
||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe, and/or does this work with AOT? Like IL2CPP and
net6.0-ios
for example?Just curious if it'll at least return
null
or it'll throw