Skip to content

Commit 31ec162

Browse files
authored
[bgen] Show more than one BE1077 error before bailing completely. (#22480)
1 parent e617d86 commit 31ec162

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

src/bgen/Generator.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,6 +4205,7 @@ string GetReturnType (AsyncMethodInfo minfo)
42054205
return "Task<" + ttype + ">";
42064206
}
42074207

4208+
HashSet<string>? reported1077;
42084209
string GetAsyncTaskType (AsyncMethodInfo minfo)
42094210
{
42104211
if (minfo.IsSingleArgAsync)
@@ -4216,8 +4217,16 @@ string GetAsyncTaskType (AsyncMethodInfo minfo)
42164217
if (attr.ResultType is not null)
42174218
return TypeManager.FormatType (minfo.type, attr.ResultType);
42184219

4219-
//Console.WriteLine ("{0}", minfo.MethodInfo.GetParameters ().Last ().ParameterType);
4220-
throw new BindingException (1077, true, minfo.mi);
4220+
var method = minfo.mi.ToString ();
4221+
if (reported1077 is null)
4222+
reported1077 = new HashSet<string> ();
4223+
4224+
if (!reported1077.Contains (method)) {
4225+
reported1077.Add (method);
4226+
exceptions.Add (ErrorHelper.CreateError (1077, method));
4227+
}
4228+
4229+
return "placeholder";
42214230
}
42224231

42234232
string GetInvokeParamList (ParameterInfo [] parameters, bool suffix = true, bool force = false)

tests/generator/ErrorTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ public void BI1060 (Profile profile)
234234
bgen.AssertWarning (1060, "The Bug42855Tests.MyFooClass protocol is decorated with [Model], but not [BaseType]. Please verify that [Model] is relevant for this protocol; if so, add [BaseType] as well, otherwise remove [Model].");
235235
}
236236

237+
[Test]
238+
[TestCase (Profile.iOS)]
239+
public void BI1077 (Profile profile)
240+
{
241+
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
242+
var bgen = new BGenTool ();
243+
bgen.Profile = profile;
244+
bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bi1077.cs")));
245+
bgen.AssertExecuteError ("build");
246+
bgen.AssertError (1077, "Async method System.Void A(BI1077.ADelegate) with more than one result parameter in the callback by neither ResultTypeName or ResultType");
247+
bgen.AssertError (1077, "Async method System.Void B(BI1077.BDelegate) with more than one result parameter in the callback by neither ResultTypeName or ResultType");
248+
bgen.AssertErrorCount (2);
249+
}
250+
237251
[Test]
238252
[TestCase (Profile.iOS)]
239253
public void BI1112_Bug37527_WrongProperty (Profile profile)

tests/generator/bi1077.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Foundation;
2+
3+
namespace BI1077 {
4+
5+
delegate void ADelegate (int a, int b, int c);
6+
delegate void BDelegate (int a, int b, int c);
7+
8+
[BaseType (typeof (NSObject))]
9+
partial interface BI1059 {
10+
[Export ("a:")]
11+
[Async]
12+
void A (ADelegate callback);
13+
14+
[Export ("B:")]
15+
[Async]
16+
void B (BDelegate callback);
17+
}
18+
19+
}

0 commit comments

Comments
 (0)