Skip to content
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

Don't warn about Foundation.NSString #4

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions MemoryAnalyzers/MemoryAnalyzers.Test/MemoryAnalyzersUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ class MyViewSubclass : UIView
await VerifyCS.VerifyAnalyzerAsync(test);
}

[TestMethod]
public async Task NSStringFieldIsOK()
{
var test = """
class MyCustomCell : UITableViewCell
{
static readonly NSString MyCellId = new NSString("MyCustomCell");
}
""";

await VerifyCS.VerifyAnalyzerAsync(test);
}

[TestMethod]
public async Task UIView_CAShapeLayer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public UnconditionalSuppressMessageAttribute(string category, string checkId)
}
""");

// Foundation.NSObject
// Foundation
testState.Sources.Add("""
namespace Foundation;

Expand All @@ -120,33 +120,32 @@ public RegisterAttribute(string name, bool isWrapper)

[Register("NSObject", isWrapper: true)]
class NSObject { }

[Register("NSString", isWrapper: true)]
class NSString : NSObject
{
public NSString(string text) { }
}
""");

// UIKit.UIView
// UIKit
testState.Sources.Add("""
namespace UIKit;

[Register("UIView", isWrapper: true)]
class UIView : NSObject { }
""");

// UIKit.UIColor
testState.Sources.Add("""
namespace UIKit;

[Register("UIColor", true)]
class UIColor : NSObject { }
""");

// UIKit.UIImage
testState.Sources.Add("""
namespace UIKit;

[Register("UIImage", true)]
class UIImage : NSObject { }

[Register("UITableViewCell", true)]
class UITableViewCell : UIView { }
""");

// CoreAnimation.CALayer
// CoreAnimation
testState.Sources.Add("""
namespace CoreAnimation;

Expand Down
2 changes: 2 additions & 0 deletions MemoryAnalyzers/MemoryAnalyzers/MemoryAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static readonly HashSet<(string Namespace, string Name)> GenerallySafe = new()
{ ("UIKit", "UIColor") },
// UIImage is fine
{ ("UIKit", "UIImage") },
// NSString is fine
{ ("Foundation", "NSString") },
};

/// <summary>
Expand Down