[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:
Sebastien Pouliot 2019-08-30 10:47:48 -04:00 коммит произвёл GitHub
Родитель 344dadb212
Коммит c3d721e318
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -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 ("}");