-
-
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
Filesystem usage analyzer #3725
base: main
Are you sure you want to change the base?
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.Analyzers/Resources.resx
Outdated
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<data name="SN0001Description" xml:space="preserve"> | ||
<value>Route file system access through IFileSystem wrapper.</value><comment>An optional longer localizable description of the diagnostic.</comment> |
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 it's optional, can we got without them? If not, I suggest taking more details from the ticket that introduced this requirement (tldr: Switch file system requirements)
<value>Route file system access through IFileSystem wrapper.</value><comment>An optional longer localizable description of the diagnostic.</comment> | |
<value>Route file system access through IFileSystem wrapper.</value> |
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 completely dropped the resx and hardcoded the warning, since I assume that no warning translations will be needed.
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? |
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?