Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
88ce274
Add basic enum basetype tests
IISResetMe Nov 21, 2018
06ff8a3
Add optional base type to enum parsing rule
IISResetMe Nov 21, 2018
e120158
WIP: Variable underlying types for enum definitions
IISResetMe Nov 21, 2018
f58eba8
Add support for Flags() and fix implied member literal values
IISResetMe Nov 21, 2018
c1bc80d
Fix CodeFactor issue (SA1116)
IISResetMe Nov 21, 2018
f417453
Add type-aware range check for enum member values
IISResetMe Nov 21, 2018
5d1ff8a
Reset tokenizer mode in EnumDefinitionRule
IISResetMe Nov 21, 2018
fc5a608
Update error strings, add null check for Enum member values
IISResetMe Nov 21, 2018
48ac5b3
Fix CodeFactor issue (SA1000, SA1019)
IISResetMe Nov 21, 2018
55ee223
Fix valueTooBig test (off-by-one) in DefineEnum()
IISResetMe Nov 21, 2018
661e7c7
Fix type names in enum test
IISResetMe Nov 21, 2018
84edbf9
Add more enum tests
IISResetMe Nov 22, 2018
d4486d8
Better error handling + parser errors for invalid enum underlying type
IISResetMe Nov 22, 2018
b0371ba
Optimize counter branch when defining enum member values
iSazonov Nov 22, 2018
dd6eee9
Add enum type constraint check to parser
IISResetMe Nov 22, 2018
548b6cd
Merge branch 'feature/enum-with-underlying-type' of https://github.co…
IISResetMe Nov 22, 2018
1c767a9
Update enum type constraint test
IISResetMe Nov 22, 2018
c43da74
Remove redundant enum type check from PSType
IISResetMe Nov 22, 2018
19b2770
Clean up DefineEnum()
IISResetMe Nov 22, 2018
d7a90a2
Fix CodeFactor issues (SA1116, SA1001)
IISResetMe Nov 22, 2018
ba4ccac
Add enum negative value tests
IISResetMe Nov 23, 2018
46c654a
Refactor enum underlying type check
IISResetMe Nov 23, 2018
c6b2951
Change enum type parser check to TypeCode
IISResetMe Nov 23, 2018
434bbab
Fix ReportError()/ReportIncompleteInput() argument alignment in Parser
IISResetMe Nov 23, 2018
61234b9
Revert "Fix ReportError()/ReportIncompleteInput() argument alignment …
IISResetMe Nov 24, 2018
dbb4d18
Simplify type names
IISResetMe Nov 24, 2018
23f2622
Update EnumDefinitionRule syntax description
IISResetMe Nov 27, 2018
b18213e
Fix argument indentation
IISResetMe Nov 27, 2018
052c093
Expand test for enum with negative initial value
IISResetMe Nov 27, 2018
1c8c5ad
Remove binary enum value incrementations when Flags() is present
IISResetMe Nov 27, 2018
4c882f4
Remove test for binary enum value incrementations when Flags() is pre…
IISResetMe Nov 27, 2018
6d283d3
Rename ParserStrings.EnumeratorValueTooLarge
IISResetMe Jan 12, 2019
80e119c
Add test for enum literal value too small
IISResetMe Jan 12, 2019
065e151
Fix comment + variable casing
IISResetMe Jan 13, 2019
456d30b
Merge branch 'master' into feature/enum-with-underlying-type
IISResetMe Jan 13, 2019
85c36a8
Fix variable casing for ValidUnderlyingTypeCodes
IISResetMe Jan 13, 2019
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
Prev Previous commit
Next Next commit
Fix argument indentation
Aligned arguments passed to ReportError() and ReportIncompleteInput() in a single column in the code paths modified
  • Loading branch information
IISResetMe committed Nov 27, 2018
commit b18213ee79c63a30f4e3583ce1332dfdb047f08c
15 changes: 10 additions & 5 deletions src/System.Management.Automation/engine/parser/PSType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,14 +1150,16 @@ internal void DefineEnum()
if (constValue != null &&
LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(constValue.GetType())))
{
_parser.ReportError(enumerator.InitialValue.Extent,
_parser.ReportError(
enumerator.InitialValue.Extent,
nameof(ParserStrings.EnumeratorValueTooLarge),
ParserStrings.EnumeratorValueTooLarge,
ToStringCodeMethods.Type(underlyingType));
}
else
{
_parser.ReportError(enumerator.InitialValue.Extent,
_parser.ReportError(
enumerator.InitialValue.Extent,
nameof(ParserStrings.CannotConvertValue),
ParserStrings.CannotConvertValue,
ToStringCodeMethods.Type(underlyingType));
Expand All @@ -1166,7 +1168,8 @@ internal void DefineEnum()
}
else
{
_parser.ReportError(enumerator.InitialValue.Extent,
_parser.ReportError(
enumerator.InitialValue.Extent,
nameof(ParserStrings.EnumeratorValueMustBeConstant),
ParserStrings.EnumeratorValueMustBeConstant);
}
Expand All @@ -1176,15 +1179,17 @@ internal void DefineEnum()

if (valueTooBig)
{
_parser.ReportError(enumerator.Extent,
_parser.ReportError(
enumerator.Extent,
nameof(ParserStrings.EnumeratorValueTooLarge),
ParserStrings.EnumeratorValueTooLarge,
ToStringCodeMethods.Type(underlyingType));
}

if (definedEnumerators.Contains(enumerator.Name))
{
_parser.ReportError(enumerator.Extent,
_parser.ReportError(
enumerator.Extent,
nameof(ParserStrings.MemberAlreadyDefined),
ParserStrings.MemberAlreadyDefined,
enumerator.Name);
Expand Down
9 changes: 6 additions & 3 deletions src/System.Management.Automation/engine/parser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4542,7 +4542,8 @@ private StatementAst EnumDefinitionRule(List<AttributeBaseAst> customAttributes,
var name = SimpleNameRule();
if (name == null)
{
ReportIncompleteInput(After(enumToken),
ReportIncompleteInput(
After(enumToken),
nameof(ParserStrings.MissingNameAfterKeyword),
ParserStrings.MissingNameAfterKeyword,
enumToken.Text);
Expand All @@ -4564,7 +4565,8 @@ private StatementAst EnumDefinitionRule(List<AttributeBaseAst> customAttributes,
underlyingType = this.TypeNameRule(allowAssemblyQualifiedNames: false, firstTypeNameToken: out unused);
if (underlyingType == null)
{
ReportIncompleteInput(After(colonToken),
ReportIncompleteInput(
After(colonToken),
nameof(ParserStrings.TypeNameExpected),
ParserStrings.TypeNameExpected);
Comment thread
IISResetMe marked this conversation as resolved.
}
Expand All @@ -4573,7 +4575,8 @@ private StatementAst EnumDefinitionRule(List<AttributeBaseAst> customAttributes,
var resolvedType = underlyingType.GetReflectionType();
if (resolvedType == null || !validUnderlyingTypeCodes.HasFlag(resolvedType.GetTypeCode()))
{
ReportError(underlyingType.Extent,
ReportError(
underlyingType.Extent,
nameof(ParserStrings.InvalidUnderlyingType),
Comment thread
IISResetMe marked this conversation as resolved.
ParserStrings.InvalidUnderlyingType,
underlyingType.Name);
Expand Down