[generator] Fix CS1522 warning building generated bindings (#6881)
It's now possible to have an empty smart `enum` but this was generating an empty switch statement that `csc` would warn us about, e.g. ``` build/{profile}/ASAuthorizationProviderAuthorizationOperation.g.cs(64,24): warning CS1522: Empty switch block ``` This fix the generation to skip the `switch` generation when no fields are present in the enum.
This commit is contained in:
Родитель
344dadb212
Коммит
c3d721e318
|
@ -165,6 +165,8 @@ public partial class Generator {
|
|||
print ("{");
|
||||
indent++;
|
||||
print ("IntPtr ptr = IntPtr.Zero;");
|
||||
// can be empty - and the C# compiler emit `warning CS1522: Empty switch block`
|
||||
if (fields.Count > 0) {
|
||||
print ("switch (({0}) self) {{", underlying_type);
|
||||
var default_symbol_name = default_symbol?.Item2.SymbolName;
|
||||
// more than one enum member can share the same numeric value - ref: #46285
|
||||
|
@ -179,6 +181,7 @@ public partial class Generator {
|
|||
indent--;
|
||||
}
|
||||
print ("}");
|
||||
}
|
||||
print ("return (NSString) Runtime.GetNSObject (ptr);");
|
||||
indent--;
|
||||
print ("}");
|
||||
|
|
Загрузка…
Ссылка в новой задаче