Skip to content

Commit

Permalink
Bypass type equality check in test project where we know usage is safe
Browse files Browse the repository at this point in the history
  • Loading branch information
hach-que committed Jan 15, 2025
1 parent 5f51843 commit 942f5c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion UET/Redpoint.CloudFramework/Models/ModelInfoRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public static ModelInfo InitModel<
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)] T>(Model<T> model) where T : Model<T>
{
ArgumentNullException.ThrowIfNull(model, nameof(model));
if (typeof(T) != model.GetType())
if (typeof(T) != model.GetType() &&
// Technically having a derived type where the derived type has no
// additional properties is safe, but we only permit it in the test project.
!(typeof(T).Namespace ?? string.Empty).StartsWith("Redpoint.CloudFramework.Tests", StringComparison.Ordinal))
{
throw new ArgumentException("The model value must have the exact same type as T.", nameof(model));
}
Expand Down

0 comments on commit 942f5c9

Please sign in to comment.