Skip to content

Commit

Permalink
Fixed issues after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasherceg committed Jul 30, 2023
1 parent f0fe7d4 commit 876d386
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export function addErrors(errors: ValidationErrorDescriptor[], options: AddError

ValidationError.attach(prop.errorMessage, propertyPath, property);
} catch (err) {
logWarning("validation", `Unable to find viewmodel property ${propertyPath}. If you've added this validation error using Context.AddModelError, make sure the property path is correct and that the object hasn't been removed from the viewmodel.`, err);
logWarning("validation", err);
}
}

Expand Down
36 changes: 0 additions & 36 deletions src/Framework/Framework/Utils/ReflectionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,41 +647,5 @@ public static IEnumerable<Type> GetBaseTypesAndInterfaces(Type type)
type = baseType;
}
}

private static volatile bool customPrimitiveTypesRegistered = false;
internal static void RegisterCustomPrimitiveTypes(IList<CustomPrimitiveTypeRegistration> customPrimitiveTypeRegistrations)
{
foreach (var registration in customPrimitiveTypeRegistrations)
{
if (IsPrimitiveType(registration.ServerSideType)
|| IsCollection(registration.ServerSideType)
|| IsDictionary(registration.ServerSideType))
{
throw new DotvvmConfigurationException($"The type {registration.ServerSideType} cannot be used as a custom primitive type. Custom primitive types cannot be collections, dictionaries, and cannot be primitive types already supported by DotVVM.");
}
if (CustomPrimitiveTypes.ContainsKey(registration.ServerSideType))
{
throw new DotvvmConfigurationException($"The type {registration.ServerSideType} is already registered as a custom primitive type.");
}
if (!PrimitiveTypes.Contains(registration.ClientSideType.UnwrapNullableType()))
{
throw new DotvvmConfigurationException($"The custom primitive type {registration.ServerSideType} cannot use {registration.ClientSideType} as a client-side equivalent. Only primitive types (strings, numbers, Guid, date and time types) are supported.");
}

CustomPrimitiveTypes.Add(registration.ServerSideType, registration);
}
customPrimitiveTypesRegistered = true;
}

internal static IEnumerable<JsonConverter> GetCustomPrimitiveTypeJsonConverters()
{
if (!customPrimitiveTypesRegistered)
{
throw new InvalidOperationException("Cannot access DefaultSerializerSettingsProvider.Instance before DotvvmConfiguration was initialized!");
}
return CustomPrimitiveTypes.Values
.Where(t => t.JsonConverter != null)
.Select(t => t.JsonConverter!);
}
}
}

0 comments on commit 876d386

Please sign in to comment.