Skip to content

Commit

Permalink
Add support for Flags() and fix implied member literal values
Browse files Browse the repository at this point in the history
  • Loading branch information
IISResetMe committed Nov 21, 2018
1 parent e120158 commit f58eba8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/System.Management.Automation/engine/parser/PSType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,15 @@ internal void DefineEnum()
definedEnumerators.Add(enumerator.Name);
enumBuilder.DefineLiteral(enumerator.Name, value);
}

if (_enumDefinitionAst.Attributes.Any(attr => attr.TypeName.GetReflectionType() == typeof(FlagsAttribute)) && value != 0)
{
value *= 2;
}
else
{
value += 1;
}
}
_enumDefinitionAst.Type = enumBuilder.CreateTypeInfo().AsType();
}
Expand Down

0 comments on commit f58eba8

Please sign in to comment.