Skip to content
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
8 changes: 8 additions & 0 deletions src/generator-enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ static string GetCSharpTypeName (Type type)
}
}

void CopyObsolete (ICustomAttributeProvider provider)
{
foreach (ObsoleteAttribute oa in provider.GetCustomAttributes (typeof (ObsoleteAttribute), false))
print ("[Obsolete (\"{0}\", {1})]", oa.Message, oa.IsError ? "true" : "false");
}

// caller already:
// - setup the header and namespace
// - call/emit PrintPlatformAttributes on the type
Expand All @@ -70,6 +76,7 @@ void GenerateEnum (Type type)
else
print ("[Native (\"{0}\")]", native.NativeName);
}
CopyObsolete (type);

var unique_constants = new HashSet<string> ();
var fields = new Dictionary<FieldInfo, FieldAttribute> ();
Expand All @@ -83,6 +90,7 @@ void GenerateEnum (Type type)
if (f.IsSpecialName)
continue;
PrintPlatformAttributes (f);
CopyObsolete (f);
print ("{0} = {1},", f.Name, f.GetRawConstantValue ());
var fa = GetAttribute<FieldAttribute> (f);
if (fa == null)
Expand Down
11 changes: 11 additions & 0 deletions tests/generator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ bug35176:
echo "Error: Expected 4 Introduced attributes in generated code."; exit 1; \
fi

bug46292:
@rm -Rf $@.tmpdir
@mkdir -p $@.tmpdir
$(if $(V),,@echo "$@";) $(IOS_GENERATOR) --sourceonly:$@.source -tmpdir=$@.tmpdir $@.cs --process-enums
@if ! grep -r Obsolete bug46292.tmpdir/BindingTests > /dev/null; then \
echo "error: Could not find Obsolete attribute in generated code."; exit 1; \
fi
@if [ `grep -r Obsolete bug46292.tmpdir/BindingTests | wc -l` -ne 2 ]; then \
echo "Error: Expected 2 Obsolete attributes in generated code."; exit 1; \
fi

forcedtype:
@rm -Rf $@.tmpdir
@mkdir -p $@.tmpdir
Expand Down
13 changes: 13 additions & 0 deletions tests/generator/bug46292.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using MonoTouch.Foundation;

namespace BindingTests {
[Obsolete ("Type level obsolete must also be copied")]
public enum HMAccessoryCategoryType : int {
[Field ("HMAccessoryCategoryTypeGarageDoorOpener")]
GarageDoorOpener = 0,

[Obsolete ("Use GarageDoorOpener")]
DoorOpener = GarageDoorOpener,
}
}