mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 01:35:40 +00:00
[Bind] Implemented CLS-compliant checks for Enums
This commit is contained in:
parent
ead151ea4f
commit
c046584aaf
|
@ -507,6 +507,8 @@ namespace Bind
|
|||
|
||||
if (@enum.IsObsolete)
|
||||
sw.WriteLine("[Obsolete(\"{0}\")]", @enum.Obsolete);
|
||||
if (!@enum.CLSCompliant)
|
||||
sw.WriteLine("[CLSCompliant(false)]");
|
||||
if (@enum.IsFlagCollection)
|
||||
sw.WriteLine("[Flags]");
|
||||
sw.WriteLine("public enum " + @enum.Name + " : " + @enum.Type);
|
||||
|
|
|
@ -98,6 +98,25 @@ namespace Bind
|
|||
e.Name = name;
|
||||
processed_enums.Add(e.Name, e);
|
||||
}
|
||||
|
||||
// Mark enums differing only in case as not CLS-compliant.
|
||||
var list = enums.Values.ToList();
|
||||
while (list.Count > 0)
|
||||
{
|
||||
var e1 = list.Last();
|
||||
list.RemoveAt(list.Count - 1);
|
||||
|
||||
var e2 = list.FirstOrDefault(l => String.Compare(e1.Name, l.Name, true) == 0);
|
||||
if (e2 != null)
|
||||
{
|
||||
e1.CLSCompliant = false;
|
||||
e2.CLSCompliant = false;
|
||||
}
|
||||
}
|
||||
foreach (var e in enums.Values)
|
||||
{
|
||||
}
|
||||
|
||||
return processed_enums;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ namespace Bind.Structures
|
|||
{
|
||||
string _name, _type;
|
||||
|
||||
public Enum()
|
||||
{
|
||||
CLSCompliant = true;
|
||||
}
|
||||
|
||||
// Returns true if the enum contains a collection of flags, i.e. 1, 2, 4, 8, ...
|
||||
public bool IsFlagCollection
|
||||
{
|
||||
|
@ -72,6 +77,8 @@ namespace Bind.Structures
|
|||
|
||||
public string Obsolete { get; set; }
|
||||
public bool IsObsolete { get { return !String.IsNullOrEmpty(Obsolete); } }
|
||||
|
||||
public bool CLSCompliant { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue