-
-
Notifications
You must be signed in to change notification settings - Fork 221
Filesystem usage analyzer #3725
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
Filesystem usage analyzer #3725
Conversation
This is really awesome and promising. Thank you! Is there a way to ignore some places where we it would be safe to call from, for example the CFunction one perhaps will be |
Is there a reason why you could not use |
That makes sense,
I also think it's kind of odd, but it's not a big deal. Alternatively it could be a new top level directory:
We only really need this on We'd include that here too: https://github.com/getsentry/sentry-unity/tree/main/src/Sentry.Unity |
src/Sentry/Sentry.csproj
Outdated
@@ -49,6 +49,10 @@ | |||
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" /> | |||
</ItemGroup> | |||
|
|||
<ItemGroup> | |||
<ProjectReference Include="..\Sentry.Analyzers\Sentry.Analyzers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> |
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.
Does this need PrivateAssets>all
?
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.
If I understand the docs correctly, it could have even been fine, but I added it anyway. I also added private assets in analyzer references.
Analyzer will only be used internally within SDK, so warning translation is not needed
Can you provide some comments or should I just disable the warning in currently offending files?
Then I will keep it simple for now and leave it as it is. I added the README, but was not able to remove the one added via Directory.Build.props to the project, so I hope that is OK.
I guess it makes sense to first merge it here and then add it in the other repo, right? |
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.
Looks good.
Doesn't seem to be draft anymore, ready for a final pass and merge?
|
||
<RootNamespace>Sentry.Analyzers</RootNamespace> | ||
<AssemblyName>Sentry.Analyzers</AssemblyName> |
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.
afaik these default to the project name so are redundant
<RootNamespace>Sentry.Analyzers</RootNamespace> | |
<AssemblyName>Sentry.Analyzers</AssemblyName> |
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.
I removed them
The current ones can be skipped, thanks
Sounds good
Definitely, that was just a note for reference, doesn't affect this PR. Can be a follow up if you'd like to contribute further 🙏 |
I added the pragmas in all the places, but this requires changes to this submodule. If I understand correctly this needs to be merged first to main and then reference in this PR adjusted? I am not used to this submodule workflow, so I hope I am doing it right. 😅
I will give it a try. 🙂 |
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.
I love this! thank you so much
@@ -30,7 +30,10 @@ public FileDiagnosticLogger(string path, bool alsoWriteToConsole = false) | |||
public FileDiagnosticLogger(string path, SentryLevel minimalLevel, bool alsoWriteToConsole = false) | |||
: base(minimalLevel) | |||
{ | |||
// Allow direct file system usage | |||
#pragma warning disable SN0001 |
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.
Ah good point, @bitsandfoxes anything we need to do to make this "Not available on Switch" ?
Edge case since someoen needs to get out of their way to use this and its' just for debugging, but this analyzier really help us make these calls now.
Not doing anything about this (just ignoring it) is fine by me too but we should add a note to the docs that this thing isn't supported on Switch anyway:
https://docs.sentry.io/platforms/unity/configuration/diagnostic-logger/#FileDiagnosticLogger
I'll leave it for @jamescrosswell to do the merging as he's the maintainer but LGTM! 🙏 |
Improved comment Co-authored-by: Bruno Garcia <[email protected]>
Hey @RRode, up until now we've been maintaining the Sentry fork of Ben.Demystifier purely for use in the sentry-dotnet repository so the workflows for changing code in there are a bit obscure and not very contributor friendly (the code used by Worst case, I can cherry pick the change from your PR and get it in there but I'd rather tidy up the submodule so it's easier to accept contributions. Give me a couple days. |
Hi @RRode, I ended up just cherry picking your changes and pushing these up. |
@jamescrosswell I pushed the missing warning disable for AndroidHelpers |
Thanks @RRode - apologies in advance if the build breaks on this one. GitHub just changed their macos-14 runners (no longer support XCode 16.0) so we need to bump to macos-15 but that's missing a bunch of stuff we need. Once this is merged, we can pull the changes into this branch and the build should work again: |
@jamescrosswell no problem. What about this format code check? Is there some doing from my side? If I understand this correctly, git fails to do something with my branch. |
Hm, possibly it's getting confused because there are multiple remotes defined for the Ben.Demystifier submodule (getsentry/Ben.Demystifier and benadams/Ben.Demystifier). The benadams (upstream) seems to be dead - it hasn't been updated forever and we can't get in touch with Ben so maybe we just remove that remote. I'll look into it once we've fixed the macos builds. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3725 +/- ##
==========================================
+ Coverage 75.73% 76.47% +0.74%
==========================================
Files 357 388 +31
Lines 13466 14196 +730
Branches 2671 2857 +186
==========================================
+ Hits 10198 10857 +659
- Misses 2593 2642 +49
- Partials 675 697 +22 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Hm, actually I think it might be an issue with
In your case, the PR is coming from a fork so it's not finding the I'm in GMT+12 so it's kind of late on a Friday night here, but I'll look into it on the weekend or early next week. |
Finally got it over the line. Thanks for your patience and huge thank you for the PR @RRode ! |
Happy to help! 🙂 |
Resolves #3643
Implements analyzer that searches for file system usage and suggests IFileSystem usage. Currently checks for usages of File, FileInfo, Directory and DirectoryInfo. No warning is produced, if these are used within IFileSystem implementation.
Analyzer was added to Sentry project and finds usage of file system outside of IFileSystem implementations, which then breaks the build. Usages found in PortablePdbReader.cs, CFunctions.cs and FileDiagnosticLogger.cs.
@bitsandfoxes Is this roughly what you had in mind?
#skip-changelog