-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
67 method with a default enum parameter wich type is byte does not co…
…mpile (#70) * feat: Add byte enum to method params * wip: fix tests * feat: add more tests for enums * feat: docs * feat: tests using verify * feat: Use simons idea on how to avoid having two similar SymbolDisplayFormats * feat: better enum testing
- Loading branch information
1 parent
1afa5e3
commit 8e451ff
Showing
15 changed files
with
289 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithByteEnums.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
void MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithByteEnumsAsReturnType.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
global::AutomaticInterfaceExample.EnumWithByteType MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithByteEnumsProperties.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.SomeProperty" /> | ||
global::AutomaticInterfaceExample.EnumWithByteType SomeProperty { get; set; } | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithEnum-byte.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
void MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithEnum-int.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
void MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithEnum-long.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
void MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithEnum.received.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
void MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
1 change: 1 addition & 0 deletions
1
AutomaticInterface/Tests/Enums/Enums.WorksWithEnum.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithEnumsAsReturnType.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
global::AutomaticInterfaceExample.EnumWithByteType MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Enums/Enums.WorksWithFlagEnum.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.MethodWithDefaultParameter(AutomaticInterfaceExample.EnumWithByteType)" /> | ||
void MethodWithDefaultParameter(global::AutomaticInterfaceExample.EnumWithByteType a = global::AutomaticInterfaceExample.EnumWithByteType.B); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
namespace Tests.Enums; | ||
|
||
public class Enums | ||
{ | ||
[Theory] | ||
[InlineData("byte")] | ||
[InlineData("int")] | ||
[InlineData("long")] | ||
public async Task WorksWithEnum(string enumName) | ||
{ | ||
var code = $$""" | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample; | ||
public enum EnumWithByteType : {{enumName}} { A = 1, B = 2, C = 3 }; | ||
[GenerateAutomaticInterface] | ||
public class DemoClass | ||
{ | ||
public void MethodWithDefaultParameter(EnumWithByteType a = EnumWithByteType.B) { } | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)) | ||
.UseMethodName($"{nameof(WorksWithEnum)}-{enumName}"); | ||
} | ||
|
||
[Fact] | ||
public async Task WorksWithFlagEnum() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample; | ||
[Flags] | ||
public enum EnumWithByteType { A = 1, B = 2, C = 3 }; | ||
[GenerateAutomaticInterface] | ||
public class DemoClass | ||
{ | ||
public void MethodWithDefaultParameter(EnumWithByteType a = EnumWithByteType.B) { } | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
|
||
[Fact] | ||
public async Task WorksWithEnumsAsReturnType() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample; | ||
public enum EnumWithByteType { A = 1, B = 2, C = 3 }; | ||
[GenerateAutomaticInterface] | ||
public class DemoClass | ||
{ | ||
public EnumWithByteType MethodWithDefaultParameter(EnumWithByteType a = EnumWithByteType.B) { return a; } | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
|
||
[Fact] | ||
public async Task WorksWithByteEnumsProperties() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample; | ||
public enum EnumWithByteType : byte { A = 1, B = 2, C = 3 }; | ||
[GenerateAutomaticInterface] | ||
public class DemoClass | ||
{ | ||
public EnumWithByteType SomeProperty { get; set; } | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters