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

[bgen] Check for null (no) namespace when matching namespace to framework. Fixes #18025. #18046

Merged
merged 2 commits into from
Apr 14, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bgen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,8 @@ static string FindNamespace (MemberInfo item)
bool IsInSupportedFramework (MemberInfo klass, PlatformName platform)
{
string ns = FindNamespace (klass);
if (string.IsNullOrEmpty (ns))
return false;
var list = GetFrameworkListForPlatform (platform);
return list.Contains (ns.ToLower (CultureInfo.InvariantCulture));
}
Expand Down
15 changes: 15 additions & 0 deletions tests/generator/BGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,21 @@ public void Bug39614 (Profile profile)
bgen.AssertWarning (1103, "'FooType`1' does not live under a namespace; namespaces are a highly recommended .NET best practice");
}

#if !NET
[Ignore ("This only applies to .NET")]
#endif
[TestCase (Profile.iOS)]
public void Bug18035 (Profile profile)
{
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
var bgen = new BGenTool ();
bgen.Profile = profile;
bgen.AddTestApiDefinition ("bug18025.cs");
bgen.CreateTemporaryBinding ();
bgen.AssertExecute ("build");
bgen.AssertWarning (1103, "'FooType' does not live under a namespace; namespaces are a highly recommended .NET best practice");
}

[Test]
public void Bug40282 ()
{
Expand Down
9 changes: 9 additions & 0 deletions tests/generator/bug18025.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using Foundation;

[BaseType (typeof (NSObject))]
public interface FooType {
[Introduced (PlatformName.iOS, 8, 0)]
[Export ("getBar:")]
string GetBar (string bar);
}