Skip to content

Commit

Permalink
Merge branch 'main' into release/4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
acizmarik committed Jan 20, 2023
2 parents 44c9178 + 01aafd5 commit 1bfd0d6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Expand Up @@ -194,6 +194,8 @@ public class DefaultViewModel : DotvvmViewModelBase
public object Object { get; set; }
public string String { get; set; }
public DateTime DateTime { get; set; }
public DateOnly DateOnly { get; set; }
public TimeOnly TimeOnly { get; set; }
public TimeSpan TimeSpan { get; set; }
public Guid Guid { get; set; }
}
Expand Down
Expand Up @@ -29,6 +29,7 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes
var test = new Test
{
TestCode = source,
ReferenceAssemblies = ReferenceAssemblies.Net.Net60
};

test.ExpectedDiagnostics.AddRange(expected);
Expand Down
Expand Up @@ -82,6 +82,8 @@ private static ImmutableHashSet<ISymbol> CreateTypesCache(Compilation compilatio
cacheBuilder.Add(compilation.GetTypeByMetadataName("System.Guid")!);
cacheBuilder.Add(compilation.GetTypeByMetadataName("System.TimeSpan")!);
cacheBuilder.Add(compilation.GetTypeByMetadataName("System.DateTimeOffset")!);
cacheBuilder.Add(compilation.GetTypeByMetadataName("System.DateOnly")!);
cacheBuilder.Add(compilation.GetTypeByMetadataName("System.TimeOnly")!);

return cacheBuilder.ToImmutableHashSet(SymbolEqualityComparer.Default);
}
Expand Down
10 changes: 9 additions & 1 deletion src/Framework/Framework/Controls/Validator.cs
Expand Up @@ -99,7 +99,15 @@ private static void AddValidatedValue(IHtmlWriter writer, IDotvvmRequestContext
}
else
{
throw new DotvvmControlException($"Could not resolve {nameof(ValueProperty)} to a valid value binding.");
// Note: ValueProperty can sometimes contain null (BusinessPack depends on this behaviour)
// However, it certainly should not contain hard-coded values

var valueRaw = control.GetValueRaw(ValueProperty);
if (valueRaw != null)
{
// There is a hard-coded value in the ValueProperty
throw new DotvvmControlException($"{nameof(ValueProperty)} can not contain a hard-coded value.");
}
}

// render options
Expand Down
Expand Up @@ -86,7 +86,7 @@ private JObject GetEnumTypeMetadataCopy(Type type)
private ObjectMetadataWithDependencies GetObjectTypeMetadataCopy(ViewModelSerializationMap map)
{
var key = new ViewModelSerializationMapWithCulture(map, CultureInfo.CurrentUICulture.Name);
var obj = cachedObjectMetadata.GetOrAdd(key, BuildObjectTypeMetadata(map));
var obj = cachedObjectMetadata.GetOrAdd(key, _ => BuildObjectTypeMetadata(map));
return new ObjectMetadataWithDependencies((JObject)obj.Metadata.DeepClone(), obj.DependentObjectTypes, obj.DependentEnumTypes);
}

Expand Down

0 comments on commit 1bfd0d6

Please sign in to comment.