CommunityToolkit / CommunityToolkit/Maui
[Proposal] Add `MemoryAnalyzer`
- Dominant language
- C#
- Stars
- 2.7k
- Forks
- 500
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 7
Description
### Feature name
Add `MemoryAnalyzer`
### Link to discussion
https://github.com/CommunityToolkit/Maui/pull/1371
### Progress tracker
- [ ] Android Implementation
- [X] iOS Implementation
- [ ] MacCatalyst Implementation
- [ ] Windows Implementation
- [ ] Tizen Implementation
- [ ] Unit Tests
- [ ] Samples
- [ ] Documentation
### Summary
This Proposal would add a new Roslyn Analyzer: [MemoryAnalyzers](https://github.com/jonathanpeppers/memory-analyzers), a set of Roslyn C# code analyzers for finding memory leaks in iOS and MacCatalyst applications, created by @jonathanpeppers on Microsoft's .NET MAUI team.
### Motivation
The .NET MAUI team adopted `MemoryAnalyzers`, adding it to their code base in this PR: https://github.com/dotnet/maui/pull/16346/files
We should strive to avoid introducing new memory leaks and this analyzer will aid us in avoiding them.
In addition, we strive to mirror the .NET MAUI repo as closely as possible to make it easy for us to promote features from the .NET MAUI Community Toolkit into .NET MAUI. Implementing `MemoryAnalzyers` will ensure our code is production ready for .NET MAUI when the time comes to promote a feature.
### Detailed Design
### Directory.Build.props
We'll set `` for every `MemoryAnalyzer` analyzer
```xml
nullable,CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1589,CS1590,CS1592,CS1598,CS1658,CS1734,MA0001,MA0002,MA0003
```
### Every `CSPROJ` file
In every `.csproj` file, we will add a Private dependency to `MemoryAnalyzers`
```xml
runtime; build; native; contentfiles; analyzers; buildtransitive
all
```
### Device Unit Tests
We will write platform-specific unit tests for iOS, Android, Tizen, Windows and MacCatalyst to ensure that the changes proposed by `MemoryAnalyzers` does not break any existing behavior.
### Usage Syntax
```markdown
N/A
```
### Drawbacks
We are not able to implement this feature until Device Tests are available. I.e. we are currently not able to write platform-specific unit tests for frameworks such as `net7.0-ios`.
### Alternatives
None
### Unresolved Questions
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.