Skip to content

Commit f35f808

Browse files
committed
v2.5.7
- *Fixed:* Corrected issue introduced in version `2.5.5` where some strings were being incorrectly converted to a guid.
1 parent e578e59 commit f35f808

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Represents the **NuGet** versions.
44

5+
## v2.5.7
6+
- *Fixed:* Corrected issue introduced in version `2.5.5` where some strings were being incorrectly converted to a guid.
7+
58
## v2.5.6
69
- *Fixed:* Release build and publish; version `2.5.5` was not published correctly.
710

Common.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.5.6</Version>
3+
<Version>2.5.7</Version>
44
<LangVersion>preview</LangVersion>
55
<Authors>Avanade</Authors>
66
<Company>Avanade</Company>

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,17 @@ Demo:
176176
- { FirstName: Wendy, LastName: Jones, Gender: F, Birthday: 1985-03-18 }
177177
```
178178

179-
Runtime values can be used within the YAML using the value lookup notation; this notation is `^(Key)`. This will either reference the [`DataParserArgs`](./src/DbEx/Migration/Data/DataParserArgs.cs) `Parameters` property using the specified key. There are two special parameters, being `UserName` and `DateTimeNow`, that reference the same named `DataParserArgs` properties. Where not found the extended notation `^(Namespace.Type.Property.Method().etc, AssemblyName)` is used. Where the `AssemblyName` is not specified then the default `mscorlib` is assumed. The `System` root namespace is optional, i.e. it will be attempted by default. The initial property or method for a `Type` must be `static`, in that the `Type` will not be instantiated. Example as follows. These parameters (`Name=Value` pairs) can also be command-line specified.
179+
Runtime values can be used within the YAML using the value lookup notation; this notation is `^(Key)`. This will either reference the [`DataParserArgs`](./src/DbEx/Migration/Data/DataParserArgs.cs) `Parameters` property using the specified key. There are two special parameters, being `UserName` and `DateTimeNow`, that reference the same named `DataParserArgs` properties. An additional special parameter being `GuidNew`, that results in a `Guid.NewGuid`. Where not found the extended notation `^(Namespace.Type.Property.Method().etc, AssemblyName)` is used. Where the `AssemblyName` is not specified then the default `mscorlib` is assumed. The `System` root namespace is optional, i.e. it will be attempted by default. The initial property or method for a `Type` must be `static`, in that the `Type` will not be instantiated. These parameters (`Name=Value` pairs) can also be command-line specified.
180+
181+
Additionally, a column can be set with a guid representation of an integer where specified using shorthand notation; i.e. replace `^n` values where `n` is an integer with a guid equivalent; e.g. `^1` will be converted to `00000001-0000-0000-0000-000000000000`. The `DataParserArgs.ReplaceShorthandGuids` had been added to control this behavior (defaults to `true`).
182+
183+
Example as follows.
180184

181185
``` yaml
182186
Demo:
183187
- Person:
184-
- { FirstName: Wendy, Username: ^(System.Security.Principal.WindowsIdentity.GetCurrent().Name,System.Security.Principal.Windows), Birthday: ^(DateTimeNow) }
185-
- { FirstName: Wendy, Username: ^(Beef.ExecutionContext.EnvironmentUsername,Beef.Core), Birthday: ^(DateTime.UtcNow) }
188+
- { PersonId: ^1, FirstName: Wendy, Username: ^(System.Security.Principal.WindowsIdentity.GetCurrent().Name,System.Security.Principal.Windows), Birthday: ^(DateTimeNow) }
189+
- { PersonId: ^2, FirstName: Wendy, Username: ^(Beef.ExecutionContext.EnvironmentUsername,Beef.Core), Birthday: ^(DateTime.UtcNow) }
186190
```
187191

188192
Advanced capabilities, such as nested YAML/JSON can be specified to represent hierarchical relationships (see `contact->addresses` within test [`data.yaml`](./tests/DbEx.Test.Console/Data/Data.yaml) and related [`TableNameMappings`](./tests/DbEx.Test.Console/Program.cs) to map to the correct underlying database table). [`DataConfig`](./src/Dbex/Migration/Data/DataConfig.cs) can also be specified using the `*` schema to control the behaviour within the context of a YAML/JSON file as demonstrated by the test [`ContactType.json`](./tests/DbEx.Test.Console/Data/ContactType.json).

src/DbEx/Migration/Data/DataParser.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ private async Task ParseTableJsonAsync(List<DataTable> tables, DataRow? parent,
298298
{
299299
case "UserName": return ParserArgs.UserName;
300300
case "DateTimeNow": return ParserArgs.DateTimeNow;
301+
case "GuidNew": return Guid.NewGuid();
301302
default:
302303
if (ParserArgs.Parameters.TryGetValue(key, out object? dval))
303304
return dval;
@@ -317,7 +318,7 @@ private async Task ParseTableJsonAsync(List<DataTable> tables, DataRow? parent,
317318

318319
throw new DataParserException(msg);
319320
}
320-
else if (ParserArgs.ReplaceShorthandGuids && int.TryParse(value[1..], out var i))
321+
else if (ParserArgs.ReplaceShorthandGuids && value.StartsWith('^') && int.TryParse(value[1..], out var i))
321322
return new Guid(i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
322323
else
323324
return value;

0 commit comments

Comments
 (0)