Skip to content

Commit

Permalink
Merge pull request #4 from BastianBlokland/feature/generator-3.5
Browse files Browse the repository at this point in the history
Update to EnumGenerator.Core 3.5.1217
  • Loading branch information
BastianBlokland authored Aug 10, 2019
2 parents 913ed42 + 26586c7 commit 26e2581
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .ci/update-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rm -rf "$LIBRARY_DIR"
ensureDir "$LIBRARY_DIR"

info "Fetching nuget packages"
withRetry nuget install "$NUGET_PACKAGE" -OutputDirectory "$NUGET_DIR"
withRetry nuget install "$NUGET_PACKAGE" -OutputDirectory "$NUGET_DIR" -NoCache

saveDll ()
{
Expand Down
23 changes: 2 additions & 21 deletions .example/Assets/Scripts/Units.g.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,32 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Generated by: EnumGenerator.Core - 3.2.1196.0
// Generated by: EnumGenerator.Core - 3.5.1217.0
// </auto-generated>
//------------------------------------------------------------------------------

using System.CodeDom.Compiler;

[GeneratedCode("EnumGenerator.Core", "3.2.1196.0")]
[GeneratedCode("EnumGenerator.Core", "3.5.1217.0")]
public enum Units
{
HesthargTheEpic = 10,

HalranTheSweet = 20,

NewaruTheCool = 30,

FledtheTheDude = 40,

RistanTheStuff = 50,

NkeleTheWarrior = 60,

RaktrargTheMage = 70,

HukrolmTheElf = 80,

ConnchopTheOrk = 90,

OrdhesTheWizard = 100,

OdrudTheHandmaiden = 110,

NeeaTheMagnificent = 120,

CuthodTheEpic = 130,

ChopneonTheRock = 140,

TycromTheUberLord = 150,

KahvortheonTheThinker = 160,

LeofunTheDwarf = 170,

HildahildaTheFool = 180,

CynranTheBrains = 190,

ThebeorthTheMechanic = 200,
}
Binary file modified .example/Assets/lib/EnumGenerator.Core.dll
Binary file not shown.
Binary file modified .lib/EnumGenerator.Core.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion .lib/manifest.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EnumGenerator.Core.3.3.1203
EnumGenerator.Core.3.5.1217
Microsoft.Extensions.Configuration.2.2.0
Microsoft.Extensions.Configuration.Abstractions.2.2.0
Microsoft.Extensions.Configuration.Binder.2.2.0
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EnumGenerator-Unity

Unity package tool for generating c# enums based on json input files.
Unity package tool for generating c# / f# / vb / cil enums based on json input files.

## Description
If you have config in json files it can be nice to have a enum to reference in the code instead of
Expand All @@ -11,13 +11,13 @@ having to hard code values, this tool allows you to generate that enum.

```
"dependencies": {
"com.bastianblokland.enumgenerator": "https://github.com/BastianBlokland/enum-generator-unity.git#v1.3",
"com.bastianblokland.enumgenerator": "https://github.com/BastianBlokland/enum-generator-unity.git#v1.4",
...
}
```
2. Add the NuGet dependency to your project.
If your project uses a NuGet package manager you can simply add a dependency to [**EnumGenerator.Core**](https://www.nuget.org/packages/EnumGenerator.Core/) version `3.3.*`.
If your project uses a NuGet package manager you can simply add a dependency to [**EnumGenerator.Core**](https://www.nuget.org/packages/EnumGenerator.Core/) version `3.5.*`.
If you are not using a NuGet package manager you can simply copy the dll's from the [`.lib`](https://github.com/BastianBlokland/enum-generator-unity/tree/master/.lib) directory to your project.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.bastianblokland.enumgenerator",
"displayName": "Enum Generator",
"author": "Bastian Blokland",
"version": "1.0.0",
"version": "1.4.0",
"unity": "2018.4",
"description": "Tool for generating c# enums based on json input files. Repository: https://github.com/bastianblokland/enum-generator-unity",
"keywords": [
Expand Down
45 changes: 45 additions & 0 deletions src/GeneratorApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,43 @@ public static void GenerateEnumToFile(

break;

case OutputType.FSharp:
try
{
output = Utf8NoBom.GetBytes(enumDefinition.ExportFSharp(
string.IsNullOrEmpty(enumNamespace) ? "Generated" : enumNamespace,
headerMode,
indentSize,
newlineMode,
storageType));
}
catch (Exception e)
{
logger?.LogCritical($"Failed to generate fsharp: {e.Message}");
return;
}

break;

case OutputType.VisualBasic:
try
{
output = Utf8NoBom.GetBytes(enumDefinition.ExportVisualBasic(
enumNamespace,
headerMode,
indentMode,
indentSize,
newlineMode,
storageType));
}
catch (Exception e)
{
logger?.LogCritical($"Failed to generate visual-basic: {e.Message}");
return;
}

break;

case OutputType.Cil:
try
{
Expand Down Expand Up @@ -248,6 +285,10 @@ private static string GetRequiredExtension(OutputType outputType)
{
case OutputType.CSharp:
return ".cs";
case OutputType.FSharp:
return ".fs";
case OutputType.VisualBasic:
return ".vb";
case OutputType.Cil:
return ".il";
case OutputType.ClassLibrary:
Expand All @@ -263,6 +304,10 @@ private static string GetDesiredExtension(OutputType outputType)
{
case OutputType.CSharp:
return ".g.cs";
case OutputType.FSharp:
return ".g.fs";
case OutputType.VisualBasic:
return ".g.vb";
case OutputType.Cil:
return ".g.il";
case OutputType.ClassLibrary:
Expand Down
12 changes: 11 additions & 1 deletion src/OutputType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ public enum OutputType
/// <summary>
/// Produce a class-library (.dll) file.
/// </summary>
ClassLibrary = 2
ClassLibrary = 2,

/// <summary>
/// Produce a FSharp (.fs) source file.
/// </summary>
FSharp = 3,

/// <summary>
/// Produce a VisualBasic (.vb) source file.
/// </summary>
VisualBasic = 4,
}
}

0 comments on commit 26e2581

Please sign in to comment.