Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use System.Text.Json as a backend for view model serialization #1799

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

exyi
Copy link
Member

@exyi exyi commented Mar 17, 2024

All UI tests are currently passing (on Asp.Net Core), most unit tests pass on both .NET Core and .NET Framework, Owin UI tests do not start because of some assembly version conflicts.

Changes to Samples and UI tests are minimal (only dependency version changes, as this requires System.Text.Json 8):

~/c/d/src (system.text.json)> git diff main -- Samples/
diff --git a/src/Samples/Api.AspNetCore/DotVVM.Samples.BasicSamples.Api.AspNetCore.csproj b/src/Samples/Api.AspNetCore/DotVVM.Samples.BasicSamples.Api.AspNetCore.csproj
index 1e2f0ab8d..65891aed8 100644
--- a/src/Samples/Api.AspNetCore/DotVVM.Samples.BasicSamples.Api.AspNetCore.csproj
+++ b/src/Samples/Api.AspNetCore/DotVVM.Samples.BasicSamples.Api.AspNetCore.csproj
@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
   </PropertyGroup>
 
   <ItemGroup>
@@ -19,11 +19,11 @@
     <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
     <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.0" />
-    <PackageReference Include="NSwag.AspNetCore" Version="13.13.2" />
+    <PackageReference Include="NSwag.AspNetCore" Version="14.0.0" />
-    <PackageReference Include="NSwag.CodeGeneration.CSharp" Version="13.13.2" />
+    <PackageReference Include="NSwag.CodeGeneration.CSharp" Version="14.0.0" />
-    <PackageReference Include="NSwag.CodeGeneration.TypeScript" Version="13.13.2" />
+    <PackageReference Include="NSwag.CodeGeneration.TypeScript" Version="14.0.0" />
-    <PackageReference Include="NSwag.Generation.WebApi" Version="13.13.2" />
+    <PackageReference Include="NSwag.Generation.WebApi" Version="14.0.0" />
-    <PackageReference Include="NJsonSchema.CodeGeneration" Version="10.5.2" />
+    <PackageReference Include="NJsonSchema.CodeGeneration" Version="11.0.0" />
     <PackageReference Include="Faker.NETCore" Version="1.0.0" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5" />
     <PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.1.5" />
diff --git a/src/Samples/Api.Common/DotVVM.Samples.BasicSamples.Api.Common.csproj b/src/Samples/Api.Common/DotVVM.Samples.BasicSamples.Api.Common.csproj
index 81dd209ec..24f1f271f 100644
--- a/src/Samples/Api.Common/DotVVM.Samples.BasicSamples.Api.Common.csproj
+++ b/src/Samples/Api.Common/DotVVM.Samples.BasicSamples.Api.Common.csproj
@@ -11,6 +11,6 @@
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
     </PackageReference>
-    <PackageReference Include="System.Text.Json" Version="5.0.2" />
+    <PackageReference Include="System.Text.Json" Version="8.0.2" />
   </ItemGroup>
 </Project>
diff --git a/src/Samples/ApplicationInsights.Owin/DotVVM.Samples.ApplicationInsights.Owin.csproj b/src/Samples/ApplicationInsights.Owin/DotVVM.Samples.ApplicationInsights.Owin.csproj
index 85d3e5704..7babe354c 100644
--- a/src/Samples/ApplicationInsights.Owin/DotVVM.Samples.ApplicationInsights.Owin.csproj
+++ b/src/Samples/ApplicationInsights.Owin/DotVVM.Samples.ApplicationInsights.Owin.csproj
@@ -37,7 +37,7 @@
     <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.20.0" />
     <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.20.0" />
     <PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="1.0.8" />
-    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
+    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
     <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
     <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.0.1" />
     <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" />
@@ -53,6 +53,6 @@
     <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
     <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
     <PackageReference Include="Owin" Version="1.0" />
-    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
+    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
   </ItemGroup>
 </Project>
diff --git a/src/Samples/AspNetCore/DotVVM.Samples.BasicSamples.AspNetCore.csproj b/src/Samples/AspNetCore/DotVVM.Samples.BasicSamples.AspNetCore.csproj
index 3d8e953ab..ccbe3a556 100644
--- a/src/Samples/AspNetCore/DotVVM.Samples.BasicSamples.AspNetCore.csproj
+++ b/src/Samples/AspNetCore/DotVVM.Samples.BasicSamples.AspNetCore.csproj
@@ -1,6 +1,6 @@
 <Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
   <PropertyGroup>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <OutputType>Exe</OutputType>
   </PropertyGroup>
   <ItemGroup>
@@ -12,7 +12,7 @@
     <ProjectReference Include="../../Tools/HotReload/AspNetCore/DotVVM.HotReload.AspNetCore.csproj" />
   </ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
     <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
   </ItemGroup>
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
diff --git a/src/Samples/AspNetCoreLatest/DotVVM.Samples.BasicSamples.AspNetCoreLatest.csproj b/src/Samples/AspNetCoreLatest/DotVVM.Samples.BasicSamples.AspNetCoreLatest.csproj
index 20546e72c..e35a37921 100644
--- a/src/Samples/AspNetCoreLatest/DotVVM.Samples.BasicSamples.AspNetCoreLatest.csproj
+++ b/src/Samples/AspNetCoreLatest/DotVVM.Samples.BasicSamples.AspNetCoreLatest.csproj
@@ -12,7 +12,7 @@
     <ProjectReference Include="../../Tools/HotReload/AspNetCore/DotVVM.HotReload.AspNetCore.csproj" />
   </ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
     <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
     <PackageReference Include="prometheus-net.AspNetCore" Version="8.0.0-pre-230102092516-2351266" />
     <PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.0" />
diff --git a/src/Samples/MiniProfiler.Owin/DotVVM.Samples.MiniProfiler.Owin.csproj b/src/Samples/MiniProfiler.Owin/DotVVM.Samples.MiniProfiler.Owin.csproj
index e56bedeaa..1b1dad4de 100644
--- a/src/Samples/MiniProfiler.Owin/DotVVM.Samples.MiniProfiler.Owin.csproj
+++ b/src/Samples/MiniProfiler.Owin/DotVVM.Samples.MiniProfiler.Owin.csproj
@@ -23,7 +23,7 @@
 
   <ItemGroup>
     <PackageReference Include="Ben.Demystifier" Version="0.4.1" />
-    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
+    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
     <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
diff --git a/src/Samples/Owin/DotVVM.Samples.BasicSamples.Owin.csproj b/src/Samples/Owin/DotVVM.Samples.BasicSamples.Owin.csproj
index 1b85ac732..6bdf08e03 100644
--- a/src/Samples/Owin/DotVVM.Samples.BasicSamples.Owin.csproj
+++ b/src/Samples/Owin/DotVVM.Samples.BasicSamples.Owin.csproj
@@ -28,9 +28,9 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
-    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
-    <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
-    <PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
     <PackageReference Include="Microsoft.Owin.Security" Version="4.2.2" />
     <PackageReference Include="Microsoft.Owin.Security.Cookies" Version="4.2.2" />
     <PackageReference Include="Microsoft.Owin.StaticFiles" Version="4.2.2" />
diff --git a/src/Samples/Tests/Tests/Feature/StringInterpolationTests.cs b/src/Samples/Tests/Tests/Feature/StringInterpolationTests.cs
index 649967eb1..d4e8d5bb2 100644
--- a/src/Samples/Tests/Tests/Feature/StringInterpolationTests.cs
+++ b/src/Samples/Tests/Tests/Feature/StringInterpolationTests.cs
@@ -73,7 +73,7 @@ namespace DotVVM.Samples.Tests.Feature
                 var text6 = browser.Single("date-format6", SelectByDataUi);
                 var text7 = browser.Single("date-format7", SelectByDataUi);
 
-                AssertUI.TextEquals(text1, "No format: 2016-07-15T03:15:00.0000000");
+                AssertUI.TextEquals(text1, "No format: 2016-07-15T03:15:00");
                 AssertUI.TextEquals(text2, "D format: Friday, July 15, 2016 |X| d format: 7/15/2016");
                 AssertUI.TextEquals(text3, "F format: Friday, July 15, 2016 3:15:00 AM |X| f format: Friday, July 15, 2016 3:15 AM");
                 AssertUI.TextEquals(text4, "G format: 7/15/2016 3:15:00 AM |X| g format: 7/15/2016 3:15 AM");

src/Framework/Core/DotVVM.Core.csproj Outdated Show resolved Hide resolved
src/Framework/Core/ViewModel/BindAttribute.cs Show resolved Hide resolved
throw new NotSupportedException(string.Format("resource collection name {0} is not supported", prop.Key));
}
return repo;
throw new NotImplementedException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ask if VS Extension needs this

return rt;
}
throw new NotImplementedException();
// var rt = new DotvvmRouteTable();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ask if VS extension needs this.

exyi and others added 15 commits April 26, 2024 13:53
* fix debug JsonConverters (must be factories to accomodate derived types)
* add charset=utf8 to all returned Content-Types
* DiagnosticsRequestTracer.ViewModelSerialized now accepts Func<Stream>
* Removed viewmodel_stringification_seconds metric as it is no longer relevant (serialization and stringification are now the same thing)
* add some [doc]comments
Just to avoid balooning this monster PR.
This specific feature is also likely to be removed, depending on the answer from VS Extension guys.
It is neccessary in order to support IGridViewDataSet type hierarchy.
The issue didn't occur before, because we didn't map interface correctly,
ignoring inherited properties. It didn't matter, because we never serialized them.
Now we can end up serializing interface if DynamicDispatch is disabled.

The shadowing allows redefining a property with another property of the same
.NET Name with a compatible type.
Not needed anymore, the types are natively supported by the serialized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants