Skip to content

Commit

Permalink
Rename ToGuid extension method. (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
chullybun committed Aug 16, 2022
1 parent 9a1796c commit d44413f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Represents the **NuGet** versions.

## v1.0.13
- *Fixed:* `Int32.ToGuid` extension method changed to `DataValueConverter.IntToGuid` to be more explicit.

## v1.0.12
- *Fixed:* `Reset` command fixed to load embedded resource file correctly.

Expand Down
2 changes: 1 addition & 1 deletion src/DbEx/DbEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>DbEx</RootNamespace>
<Version>1.0.12</Version>
<Version>1.0.13</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>DbEx Developers</Authors>
<Company>Avanade</Company>
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx/Migration/Data/DataRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void AddColumn(DataColumn column)

case "Guid":
if (int.TryParse(str, out int a))
column.Value = a.ToGuid();
column.Value = DataValueConverter.IntToGuid(a);
else
{
if (Guid.TryParse(str, out Guid g))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
namespace DbEx.Migration.Data
{
/// <summary>
/// Provides extension methods.
/// Provides data value conversion.
/// </summary>
[DebuggerStepThrough]
public static class ExtensionMethods
public static class DataValueConverter
{
/// <summary>
/// Converts an <see cref="int"/> to a <see cref="Guid"/>; e.g. '<c>1</c>' will result in '<c>00000001-0000-0000-0000-000000000000</c>'.
/// </summary>
/// <param name="value">The <see cref="int"/> value.</param>
/// <returns>The corresponding <see cref="Guid"/>.</returns>
/// <remarks>Sets the first argument with the <paramref name="value"/> and the remainder with zeroes using <see cref="Guid(int, short, short, byte[])"/>.</remarks>
public static Guid ToGuid(this int value) => new(value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
public static Guid IntToGuid(int value) => new(value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
}
2 changes: 1 addition & 1 deletion tests/DbEx.Test/SqlServerMigratorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task A120_MigrateAll_Console()

Assert.AreEqual(3, res.Count);
var row2 = res2[0];
Assert.AreEqual(88.ToGuid(), row2.PersonId);
Assert.AreEqual(DataValueConverter.IntToGuid(88), row2.PersonId);
Assert.AreEqual("RUNTIME", row2.Name);
Assert.AreEqual(m.ParserArgs.UserName, row2.CreatedBy);
Assert.AreEqual(m.ParserArgs.DateTimeNow, row2.CreatedDate);
Expand Down

0 comments on commit d44413f

Please sign in to comment.