From 397fc518d3376629a8a7e755a7fec6d16b11f911 Mon Sep 17 00:00:00 2001 From: Shannon Lewis Date: Mon, 22 Jun 2020 10:51:54 +1000 Subject: [PATCH 01/10] created TypedId and new generics interface for IId. Old IId will live in parallel until all things are migrated --- source/Octopus.Data/Model/IId.cs | 6 ++++++ source/Octopus.Data/Model/TypedId.cs | 11 +++++++++++ source/Octopus.Data/Model/User/IUser.cs | 9 ++++++++- source/Octopus.Data/Octopus.Data.csproj | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 source/Octopus.Data/Model/TypedId.cs diff --git a/source/Octopus.Data/Model/IId.cs b/source/Octopus.Data/Model/IId.cs index 24e0e64..c7e5cbb 100644 --- a/source/Octopus.Data/Model/IId.cs +++ b/source/Octopus.Data/Model/IId.cs @@ -6,4 +6,10 @@ public interface IId { string Id { get; } } + + public interface IId + where TId : TypedId + { + TId Id { get; } + } } \ No newline at end of file diff --git a/source/Octopus.Data/Model/TypedId.cs b/source/Octopus.Data/Model/TypedId.cs new file mode 100644 index 0000000..1e9341e --- /dev/null +++ b/source/Octopus.Data/Model/TypedId.cs @@ -0,0 +1,11 @@ +using Octopus.TinyTypes; + +namespace Octopus.Data.Model +{ + public class TypedId : TinyType + { + public TypedId(string value) : base(value) + { + } + } +} \ No newline at end of file diff --git a/source/Octopus.Data/Model/User/IUser.cs b/source/Octopus.Data/Model/User/IUser.cs index 1c1fb34..5796329 100644 --- a/source/Octopus.Data/Model/User/IUser.cs +++ b/source/Octopus.Data/Model/User/IUser.cs @@ -3,7 +3,7 @@ namespace Octopus.Data.Model.User { - public interface IUser : IId + public interface IUser : IId { string Username { get; } Guid IdentificationToken { get; } @@ -22,4 +22,11 @@ public interface IUser : IId SecurityGroups GetSecurityGroups(string identityProviderName); IEnumerable GetSecurityGroups(); } + + public class UserId : TypedId + { + public UserId(string value) : base(value) + { + } + } } \ No newline at end of file diff --git a/source/Octopus.Data/Octopus.Data.csproj b/source/Octopus.Data/Octopus.Data.csproj index 76ff03b..20b4cb5 100644 --- a/source/Octopus.Data/Octopus.Data.csproj +++ b/source/Octopus.Data/Octopus.Data.csproj @@ -15,10 +15,13 @@ default enable true + enable + 8 + From ec536bb849f7a477b1aa695d582f17fdc5bd9aae Mon Sep 17 00:00:00 2001 From: Shannon Lewis Date: Mon, 22 Jun 2020 11:30:59 +1000 Subject: [PATCH 02/10] added extension method to simplify converting from string to UserId --- source/Octopus.Data/Model/User/IUser.cs | 7 ------- source/Octopus.Data/Model/User/UserId.cs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 source/Octopus.Data/Model/User/UserId.cs diff --git a/source/Octopus.Data/Model/User/IUser.cs b/source/Octopus.Data/Model/User/IUser.cs index 5796329..4caab0e 100644 --- a/source/Octopus.Data/Model/User/IUser.cs +++ b/source/Octopus.Data/Model/User/IUser.cs @@ -22,11 +22,4 @@ public interface IUser : IId SecurityGroups GetSecurityGroups(string identityProviderName); IEnumerable GetSecurityGroups(); } - - public class UserId : TypedId - { - public UserId(string value) : base(value) - { - } - } } \ No newline at end of file diff --git a/source/Octopus.Data/Model/User/UserId.cs b/source/Octopus.Data/Model/User/UserId.cs new file mode 100644 index 0000000..fbe1167 --- /dev/null +++ b/source/Octopus.Data/Model/User/UserId.cs @@ -0,0 +1,17 @@ +namespace Octopus.Data.Model.User +{ + public class UserId : TypedId + { + public UserId(string value) : base(value) + { + } + } + + public static class UserIdExtensionMethods + { + public static UserId ToUserId(this string value) + { + return new UserId(value); + } + } +} \ No newline at end of file From 10b2768b03f80a68ed4ddfd46b783058ae3fafd4 Mon Sep 17 00:00:00 2001 From: Shannon Lewis Date: Wed, 22 Jul 2020 16:04:37 +1000 Subject: [PATCH 03/10] Added equality operators to TypedIds, so you can `==` against a string/int etc --- source/Octopus.Data/Model/IId.cs | 2 +- source/Octopus.Data/Model/TypedId.cs | 97 +++++++++++++++++++++++- source/Octopus.Data/Model/User/UserId.cs | 7 +- source/Tests/TypedIdOfIntTests.cs | 41 ++++++++++ source/Tests/TypedIdTests.cs | 67 ++++++++++++++++ 5 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 source/Tests/TypedIdOfIntTests.cs create mode 100644 source/Tests/TypedIdTests.cs diff --git a/source/Octopus.Data/Model/IId.cs b/source/Octopus.Data/Model/IId.cs index c7e5cbb..108c9c1 100644 --- a/source/Octopus.Data/Model/IId.cs +++ b/source/Octopus.Data/Model/IId.cs @@ -8,7 +8,7 @@ public interface IId } public interface IId - where TId : TypedId + where TId : ITypedId { TId Id { get; } } diff --git a/source/Octopus.Data/Model/TypedId.cs b/source/Octopus.Data/Model/TypedId.cs index 1e9341e..3400f27 100644 --- a/source/Octopus.Data/Model/TypedId.cs +++ b/source/Octopus.Data/Model/TypedId.cs @@ -1,11 +1,106 @@ +using System; using Octopus.TinyTypes; namespace Octopus.Data.Model { - public class TypedId : TinyType + public interface ITypedId + { + } + + public class TypedId : TypedId, ITypedId { public TypedId(string value) : base(value) { } + + public override bool Equals(object obj) + { + if (obj == null) + return false; + if ((object) this == obj) + return true; + return !(obj.GetType() != GetType()) && obj.GetHashCode() == GetHashCode(); + } + + public override int GetHashCode() + { + return GetType().GetHashCode() ^ Value.GetHashCode(); + } + + public static bool operator ==(TypedId? a, TypedId? b) + { + if ((object?)a == null && (object?)b == null) + return true; + return (object?)a != null && (object?)b != null && a.Equals(b); + } + + public static bool operator !=(TypedId a, TypedId b) + { + return !(a == b); + } + + public static bool operator ==(TypedId? a, string? b) + { + if ((object?)a == null && b == null) + return true; + return (object?)a != null && a.Value.Equals(b); + } + + public static bool operator !=(TypedId? a, string? b) + { + return !(a == b); + } + } + + public interface ITypedId : ITypedId + where T : IComparable + { + T Value { get; } + } + + public class TypedId : TinyType, ITypedId + where T : IComparable + { + public TypedId(T value) : base(value) + { + } + + public override bool Equals(object obj) + { + if (obj == null) + return false; + if ((object) this == obj) + return true; + return !(obj.GetType() != GetType()) && obj.GetHashCode() == GetHashCode(); + } + + public override int GetHashCode() + { + return GetType().GetHashCode() ^ Value.GetHashCode(); + } + + public static bool operator ==(TypedId? a, TypedId? b) + { + if ((object?)a == null && (object?)b == null) + return true; + return (object?)a != null && (object?)b != null && a.Equals(b); + } + + public static bool operator !=(TypedId? a, TypedId? b) + { + return !(a == b); + } + + public static bool operator ==(TypedId? a, T b) + { + if ((object?)a == null && b == null) + return true; + return (object?)a != null && b != null && a.Value.Equals(b); + } + + public static bool operator !=(TypedId? a, T b) + { + return !(a == b); + } } } \ No newline at end of file diff --git a/source/Octopus.Data/Model/User/UserId.cs b/source/Octopus.Data/Model/User/UserId.cs index fbe1167..89f2e5c 100644 --- a/source/Octopus.Data/Model/User/UserId.cs +++ b/source/Octopus.Data/Model/User/UserId.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace Octopus.Data.Model.User { public class UserId : TypedId @@ -9,9 +11,10 @@ public UserId(string value) : base(value) public static class UserIdExtensionMethods { - public static UserId ToUserId(this string value) + [return: NotNullIfNotNull("value")] + public static UserId? ToUserId(this string? value) { - return new UserId(value); + return value == null ? null : new UserId(value); } } } \ No newline at end of file diff --git a/source/Tests/TypedIdOfIntTests.cs b/source/Tests/TypedIdOfIntTests.cs new file mode 100644 index 0000000..685d55f --- /dev/null +++ b/source/Tests/TypedIdOfIntTests.cs @@ -0,0 +1,41 @@ +using NUnit.Framework; +using Octopus.Data.Model; + +namespace Tests +{ + [TestFixture] + public class TypedIdOfIntTests + { + [Test] + public void CanCompareUserIdToString() + { + var obj = new TestObject(new TestId(10)); + Assert.IsTrue(obj.Id == 10); + } + + [Test] + public void CanCompareUserIdToAnotherUserId() + { + var obj = new TestObject(new TestId(10)); + Assert.IsTrue(obj.Id == new TestId(10)); + } + + class TestId : TypedId + { + public TestId(int value) : base(value) + { + } + } + + class TestObject : IId + { + public TestObject(TestId id) + { + Id = id; + } + + public TestId Id { get; } + } + + } +} \ No newline at end of file diff --git a/source/Tests/TypedIdTests.cs b/source/Tests/TypedIdTests.cs new file mode 100644 index 0000000..b120bea --- /dev/null +++ b/source/Tests/TypedIdTests.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using Octopus.Data.Model.User; + +namespace Tests +{ + [TestFixture] + public class TypedIdTests + { + [Test] + public void CanCompareUserIdToString() + { + var user = new UserTest("Users-1".ToUserId(), "testuser1", "testuser@octopustest.com"); + Assert.IsTrue(user.Id == "Users-1"); + } + + [Test] + public void CanCompareUserIdToAnotherUserId() + { + var user = new UserTest("Users-1".ToUserId(), "testuser1", "testuser@octopustest.com"); + Assert.IsTrue(user.Id == "Users-1".ToUserId()); + } + + class UserTest : IUser + { + public UserTest(UserId id, string username, string emailAddress) + { + Id = id; + Username = username; + DisplayName = username; + EmailAddress = emailAddress; + IdentificationToken = Guid.NewGuid(); + Identities = new HashSet(); + IsActive = true; + } + + public UserId Id { get; } + public string Username { get; } + public Guid IdentificationToken { get; } + public string DisplayName { get; set; } + public string EmailAddress { get; set; } + public bool IsService { get; set; } + public bool IsActive { get; set; } + public HashSet Identities { get; } + public void SetPassword(string plainTextPassword) + { + throw new NotImplementedException(); + } + + public bool ValidatePassword(string plainTextPassword) + { + throw new NotImplementedException(); + } + + public SecurityGroups GetSecurityGroups(string identityProviderName) + { + throw new NotImplementedException(); + } + + public IEnumerable GetSecurityGroups() + { + throw new NotImplementedException(); + } + } + } +} \ No newline at end of file From d7d301b345f9e08a05a17687408a727e4037175b Mon Sep 17 00:00:00 2001 From: slewis74 Date: Wed, 10 Feb 2021 11:30:31 +1000 Subject: [PATCH 04/10] use real TinyTypes now they exist --- source/Octopus.Data/Model/IId.cs | 3 +- source/Octopus.Data/Model/TypedId.cs | 106 ----------------------- source/Octopus.Data/Model/User/UserId.cs | 3 +- source/Octopus.Data/Octopus.Data.csproj | 2 +- source/Tests/TypedIdOfIntTests.cs | 41 --------- source/Tests/TypedIdTests.cs | 67 -------------- 6 files changed, 5 insertions(+), 217 deletions(-) delete mode 100644 source/Octopus.Data/Model/TypedId.cs delete mode 100644 source/Tests/TypedIdOfIntTests.cs delete mode 100644 source/Tests/TypedIdTests.cs diff --git a/source/Octopus.Data/Model/IId.cs b/source/Octopus.Data/Model/IId.cs index 108c9c1..fff62a3 100644 --- a/source/Octopus.Data/Model/IId.cs +++ b/source/Octopus.Data/Model/IId.cs @@ -1,4 +1,5 @@ using System; +using Octopus.TinyTypes; namespace Octopus.Data.Model { @@ -8,7 +9,7 @@ public interface IId } public interface IId - where TId : ITypedId + where TId : CaseInsensitiveStringTinyType { TId Id { get; } } diff --git a/source/Octopus.Data/Model/TypedId.cs b/source/Octopus.Data/Model/TypedId.cs deleted file mode 100644 index 3400f27..0000000 --- a/source/Octopus.Data/Model/TypedId.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using Octopus.TinyTypes; - -namespace Octopus.Data.Model -{ - public interface ITypedId - { - } - - public class TypedId : TypedId, ITypedId - { - public TypedId(string value) : base(value) - { - } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - if ((object) this == obj) - return true; - return !(obj.GetType() != GetType()) && obj.GetHashCode() == GetHashCode(); - } - - public override int GetHashCode() - { - return GetType().GetHashCode() ^ Value.GetHashCode(); - } - - public static bool operator ==(TypedId? a, TypedId? b) - { - if ((object?)a == null && (object?)b == null) - return true; - return (object?)a != null && (object?)b != null && a.Equals(b); - } - - public static bool operator !=(TypedId a, TypedId b) - { - return !(a == b); - } - - public static bool operator ==(TypedId? a, string? b) - { - if ((object?)a == null && b == null) - return true; - return (object?)a != null && a.Value.Equals(b); - } - - public static bool operator !=(TypedId? a, string? b) - { - return !(a == b); - } - } - - public interface ITypedId : ITypedId - where T : IComparable - { - T Value { get; } - } - - public class TypedId : TinyType, ITypedId - where T : IComparable - { - public TypedId(T value) : base(value) - { - } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - if ((object) this == obj) - return true; - return !(obj.GetType() != GetType()) && obj.GetHashCode() == GetHashCode(); - } - - public override int GetHashCode() - { - return GetType().GetHashCode() ^ Value.GetHashCode(); - } - - public static bool operator ==(TypedId? a, TypedId? b) - { - if ((object?)a == null && (object?)b == null) - return true; - return (object?)a != null && (object?)b != null && a.Equals(b); - } - - public static bool operator !=(TypedId? a, TypedId? b) - { - return !(a == b); - } - - public static bool operator ==(TypedId? a, T b) - { - if ((object?)a == null && b == null) - return true; - return (object?)a != null && b != null && a.Value.Equals(b); - } - - public static bool operator !=(TypedId? a, T b) - { - return !(a == b); - } - } -} \ No newline at end of file diff --git a/source/Octopus.Data/Model/User/UserId.cs b/source/Octopus.Data/Model/User/UserId.cs index 89f2e5c..a633c70 100644 --- a/source/Octopus.Data/Model/User/UserId.cs +++ b/source/Octopus.Data/Model/User/UserId.cs @@ -1,8 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using Octopus.TinyTypes; namespace Octopus.Data.Model.User { - public class UserId : TypedId + public class UserId : CaseInsensitiveStringTinyType { public UserId(string value) : base(value) { diff --git a/source/Octopus.Data/Octopus.Data.csproj b/source/Octopus.Data/Octopus.Data.csproj index e8bc024..05f6205 100644 --- a/source/Octopus.Data/Octopus.Data.csproj +++ b/source/Octopus.Data/Octopus.Data.csproj @@ -25,7 +25,7 @@ - + diff --git a/source/Tests/TypedIdOfIntTests.cs b/source/Tests/TypedIdOfIntTests.cs deleted file mode 100644 index 685d55f..0000000 --- a/source/Tests/TypedIdOfIntTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using NUnit.Framework; -using Octopus.Data.Model; - -namespace Tests -{ - [TestFixture] - public class TypedIdOfIntTests - { - [Test] - public void CanCompareUserIdToString() - { - var obj = new TestObject(new TestId(10)); - Assert.IsTrue(obj.Id == 10); - } - - [Test] - public void CanCompareUserIdToAnotherUserId() - { - var obj = new TestObject(new TestId(10)); - Assert.IsTrue(obj.Id == new TestId(10)); - } - - class TestId : TypedId - { - public TestId(int value) : base(value) - { - } - } - - class TestObject : IId - { - public TestObject(TestId id) - { - Id = id; - } - - public TestId Id { get; } - } - - } -} \ No newline at end of file diff --git a/source/Tests/TypedIdTests.cs b/source/Tests/TypedIdTests.cs deleted file mode 100644 index b120bea..0000000 --- a/source/Tests/TypedIdTests.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using NUnit.Framework; -using Octopus.Data.Model.User; - -namespace Tests -{ - [TestFixture] - public class TypedIdTests - { - [Test] - public void CanCompareUserIdToString() - { - var user = new UserTest("Users-1".ToUserId(), "testuser1", "testuser@octopustest.com"); - Assert.IsTrue(user.Id == "Users-1"); - } - - [Test] - public void CanCompareUserIdToAnotherUserId() - { - var user = new UserTest("Users-1".ToUserId(), "testuser1", "testuser@octopustest.com"); - Assert.IsTrue(user.Id == "Users-1".ToUserId()); - } - - class UserTest : IUser - { - public UserTest(UserId id, string username, string emailAddress) - { - Id = id; - Username = username; - DisplayName = username; - EmailAddress = emailAddress; - IdentificationToken = Guid.NewGuid(); - Identities = new HashSet(); - IsActive = true; - } - - public UserId Id { get; } - public string Username { get; } - public Guid IdentificationToken { get; } - public string DisplayName { get; set; } - public string EmailAddress { get; set; } - public bool IsService { get; set; } - public bool IsActive { get; set; } - public HashSet Identities { get; } - public void SetPassword(string plainTextPassword) - { - throw new NotImplementedException(); - } - - public bool ValidatePassword(string plainTextPassword) - { - throw new NotImplementedException(); - } - - public SecurityGroups GetSecurityGroups(string identityProviderName) - { - throw new NotImplementedException(); - } - - public IEnumerable GetSecurityGroups() - { - throw new NotImplementedException(); - } - } - } -} \ No newline at end of file From 308cf95c9b78d542c78c5b6596be9b17fc3c1db4 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Wed, 10 Feb 2021 11:48:02 +1000 Subject: [PATCH 05/10] allow IDocument to define it's Id type --- source/Octopus.Data/Model/IDocument.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/Octopus.Data/Model/IDocument.cs b/source/Octopus.Data/Model/IDocument.cs index 997e340..0b1273e 100644 --- a/source/Octopus.Data/Model/IDocument.cs +++ b/source/Octopus.Data/Model/IDocument.cs @@ -1,8 +1,14 @@ using System; +using Octopus.TinyTypes; namespace Octopus.Data.Model { public interface IDocument : IId, INamed { } + + public interface IDocument : IId, INamed + where TId : CaseInsensitiveStringTinyType + { + } } \ No newline at end of file From fbf4ce43476eb4cd8c23455a2d1ca25bdef63809 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Tue, 15 Jun 2021 08:29:47 +1000 Subject: [PATCH 06/10] make IId and IId --- source/Octopus.Data/Model/IId.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/Octopus.Data/Model/IId.cs b/source/Octopus.Data/Model/IId.cs index fff62a3..c4a8441 100644 --- a/source/Octopus.Data/Model/IId.cs +++ b/source/Octopus.Data/Model/IId.cs @@ -3,13 +3,11 @@ namespace Octopus.Data.Model { - public interface IId + public interface IId : IId { - string Id { get; } } public interface IId - where TId : CaseInsensitiveStringTinyType { TId Id { get; } } From e9ea0251202a5fde93e5d7c5f53a52585dad8187 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Tue, 15 Jun 2021 09:53:28 +1000 Subject: [PATCH 07/10] Easier transition will be to make IDocument inherit IDocument, and drop the generics constraint to CaseInsensitiveTinyType --- source/Octopus.Data/Model/IDocument.cs | 4 +--- source/Octopus.Data/Model/IId.cs | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/source/Octopus.Data/Model/IDocument.cs b/source/Octopus.Data/Model/IDocument.cs index 0b1273e..c1e8f24 100644 --- a/source/Octopus.Data/Model/IDocument.cs +++ b/source/Octopus.Data/Model/IDocument.cs @@ -1,14 +1,12 @@ using System; -using Octopus.TinyTypes; namespace Octopus.Data.Model { - public interface IDocument : IId, INamed + public interface IDocument : IDocument { } public interface IDocument : IId, INamed - where TId : CaseInsensitiveStringTinyType { } } \ No newline at end of file diff --git a/source/Octopus.Data/Model/IId.cs b/source/Octopus.Data/Model/IId.cs index c4a8441..cff0579 100644 --- a/source/Octopus.Data/Model/IId.cs +++ b/source/Octopus.Data/Model/IId.cs @@ -1,5 +1,4 @@ using System; -using Octopus.TinyTypes; namespace Octopus.Data.Model { From cad5a9343f20b25a3a3d51bccc75c20ee741090b Mon Sep 17 00:00:00 2001 From: slewis74 Date: Tue, 15 Jun 2021 14:05:08 +1000 Subject: [PATCH 08/10] Added IId marker back onto IDocument --- source/Octopus.Data/Model/IDocument.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Octopus.Data/Model/IDocument.cs b/source/Octopus.Data/Model/IDocument.cs index c1e8f24..f9d7eec 100644 --- a/source/Octopus.Data/Model/IDocument.cs +++ b/source/Octopus.Data/Model/IDocument.cs @@ -2,7 +2,7 @@ namespace Octopus.Data.Model { - public interface IDocument : IDocument + public interface IDocument : IDocument, IId { } From b3b74a3547dc6ff5e916478a370cc34ed31cbcc5 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Wed, 16 Jun 2021 20:32:07 +1000 Subject: [PATCH 09/10] moving UserId to MessageContracts, as it's needed for the resources --- source/Octopus.Data/Model/User/IUser.cs | 1 + source/Octopus.Data/Model/User/UserId.cs | 21 --------------------- source/Octopus.Data/Octopus.Data.csproj | 2 +- 3 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 source/Octopus.Data/Model/User/UserId.cs diff --git a/source/Octopus.Data/Model/User/IUser.cs b/source/Octopus.Data/Model/User/IUser.cs index 4caab0e..7a72ce5 100644 --- a/source/Octopus.Data/Model/User/IUser.cs +++ b/source/Octopus.Data/Model/User/IUser.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Octopus.Server.MessageContracts.Features.Users; namespace Octopus.Data.Model.User { diff --git a/source/Octopus.Data/Model/User/UserId.cs b/source/Octopus.Data/Model/User/UserId.cs deleted file mode 100644 index a633c70..0000000 --- a/source/Octopus.Data/Model/User/UserId.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Octopus.TinyTypes; - -namespace Octopus.Data.Model.User -{ - public class UserId : CaseInsensitiveStringTinyType - { - public UserId(string value) : base(value) - { - } - } - - public static class UserIdExtensionMethods - { - [return: NotNullIfNotNull("value")] - public static UserId? ToUserId(this string? value) - { - return value == null ? null : new UserId(value); - } - } -} \ No newline at end of file diff --git a/source/Octopus.Data/Octopus.Data.csproj b/source/Octopus.Data/Octopus.Data.csproj index 05f6205..277fbb4 100644 --- a/source/Octopus.Data/Octopus.Data.csproj +++ b/source/Octopus.Data/Octopus.Data.csproj @@ -21,7 +21,7 @@ - + From 76672ca7a214b9f91903921ceba229142d05c8e1 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Thu, 17 Jun 2021 21:03:45 +1000 Subject: [PATCH 10/10] Missed conversion from string to UserId for IUserStore --- source/Octopus.Data/Storage/User/IUserStore.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Octopus.Data/Storage/User/IUserStore.cs b/source/Octopus.Data/Storage/User/IUserStore.cs index e942f48..b8b34f0 100644 --- a/source/Octopus.Data/Storage/User/IUserStore.cs +++ b/source/Octopus.Data/Storage/User/IUserStore.cs @@ -1,11 +1,12 @@ using System; using Octopus.Data.Model.User; +using Octopus.Server.MessageContracts.Features.Users; namespace Octopus.Data.Storage.User { public interface IUserStore { - IUser GetById(string userId); + IUser GetById(UserId userId); IUser GetByUsername(string username); IUser[] GetByEmailAddress(string emailAddress); IUser GetByIdentificationToken(Guid identificationToken);