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 for JSON serialization and deserialization #870

Open
wants to merge 170 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
6f1dcbc
Update playground to 6.0
ikeough Feb 17, 2022
c509b41
Add the default project assets.
ikeough Feb 17, 2022
477c3cd
Add a readme.
ikeough Feb 17, 2022
962878e
Delete unused line.
ikeough Feb 17, 2022
7fd2998
More clean up of the API.
ikeough Feb 17, 2022
b663782
Clean up the index.
ikeough Feb 17, 2022
46ef348
Removing more stuff we don't need.
ikeough Feb 17, 2022
1c41c2a
Razor imports not required.
ikeough Feb 17, 2022
d8e7632
More APIs.
ikeough Feb 17, 2022
6bdce9f
Create a temporary test button.
ikeough Feb 17, 2022
ff4a309
Disable validation on construction.
ikeough Feb 17, 2022
67f8307
Progress on System.Text.Json serialization APIs.
ikeough Feb 18, 2022
e14d4b0
Element id serialization still broken. But closer.
ikeough Feb 21, 2022
a7feb35
Refactoring into files.
ikeough Feb 22, 2022
e5305a0
Add reference resolver.
ikeough Feb 22, 2022
2856f1f
Do it all with one converter.
ikeough Feb 22, 2022
c97b42a
Some better test infrastructure.
ikeough Feb 22, 2022
4d1db85
More debugging view.
ikeough Feb 22, 2022
1b846a5
Little cleanups.
ikeough Feb 22, 2022
828efed
Cleanup.
ikeough Feb 25, 2022
d9adf81
Multi-colored test.
ikeough Feb 25, 2022
196690e
Cleanup.
ikeough Feb 25, 2022
faf48dd
Rename the wrapper.
ikeough Feb 25, 2022
6287c2d
Merge branch 'master' into wasm-minimal
ikeough Feb 25, 2022
ab3faba
Merge branch 'master' into wasm-minimal
ikeough Feb 25, 2022
8adf110
Merge branch 'master' into wasm-minimal
ikeough Feb 26, 2022
d44c0f8
Merge branch 'master' into wasm-minimal
ikeough Mar 23, 2022
6492104
Merge branch 'wasm-minimal' of https://github.com/hypar-io/Elements i…
ikeough Mar 23, 2022
40555e1
Merge branch 'master' into wasm-minimal
ikeough Apr 16, 2022
2abe2b8
Replace all newtonsoft usings with system.text.json.serialization.
ikeough Apr 16, 2022
f8dd48c
Replace all JsonProperty with JsonPropertyName.
ikeough Apr 16, 2022
f7d6946
Replace inheritance converter with ElementConverter<T>
ikeough Apr 16, 2022
def903f
Cleanup all JsonConstructor.
ikeough Apr 16, 2022
c300c7d
Convert private fields with JsonProperty.
ikeough Apr 16, 2022
8a5ee2f
Allow existing converters to use newtonsoft.
ikeough Apr 16, 2022
3179f82
Cleanup attributes in favor of system.text.json.
ikeough Apr 16, 2022
636416b
Switch to system.text.json serializer where possible.
ikeough Apr 16, 2022
769a498
Convert geojson to system.text.json.
ikeough Apr 17, 2022
801c272
Convert model methods to use new logic. All model tests pass.
ikeough Apr 17, 2022
27afc0f
Update the bridge API.
ikeough Apr 17, 2022
c27f54f
Update the readme with publish instructions.
ikeough Apr 17, 2022
5d63c31
Set publish to AOT compile.
ikeough Apr 17, 2022
ae23c60
Expose serialization constructor on topography to fix all topo tests.
ikeough Apr 17, 2022
e6b8864
Fixing joists.
ikeough Apr 19, 2022
68c0c71
Merge branch 'master' into wasm-minimal
ikeough Apr 24, 2022
6b01106
Finish fixing joists, and start adding parameterless constructors.
ikeough Apr 24, 2022
40bf6d3
Update user element tests to support collections.
ikeough Apr 25, 2022
3152fd9
Move elementwise serialization into the converter.
ikeough Apr 25, 2022
92ba6d7
Fix bbox tests.
ikeough Apr 25, 2022
3d5c675
Point to System.Text.Json's version of extension data.
ikeough Apr 25, 2022
59620e9
Fix content elements.
ikeough Apr 25, 2022
2bb069b
Clean out the json inheritance converter.
ikeough Apr 25, 2022
4218d79
Don't use the model converter by default.
ikeough Apr 25, 2022
4edb5d0
Fix one test.
ikeough Apr 25, 2022
060f64b
Fix the analysis mesh tests.
ikeough Apr 25, 2022
11f2d1b
Merge branch 'master' into wasm-minimal
ikeough Apr 25, 2022
4a93a2a
Only write during debug.
ikeough Apr 25, 2022
197c432
Fix import mesh element.
ikeough Apr 25, 2022
ac2a5ba
We must keep these for now.
ikeough Apr 25, 2022
d614678
Throw a meaningful exception and create a new API to deserialize one …
ikeough Apr 25, 2022
bb0b91e
Fifteen test fixes.
ikeough Apr 25, 2022
ab814c0
Merge branch 'master' into wasm-minimal
ikeough Apr 25, 2022
430dd3f
Merge branch 'wasm-minimal' of https://github.com/hypar-io/Elements i…
ikeough Apr 25, 2022
baa7ba1
Fix solid converter.
ikeough Apr 26, 2022
b67e6ce
Fixed all but 1 solid test.
ikeough Apr 26, 2022
4ddb913
Fix analysis image.
ikeough Apr 26, 2022
c4aafef
Fix element instance tests and user element tests.
ikeough Apr 27, 2022
149409b
Remove unused reference.
ikeough Apr 27, 2022
5ce74ab
Cleaning up more newtonsoft references.
ikeough Apr 27, 2022
0a79520
Fix color scale tests.
ikeough Apr 27, 2022
71fcebd
Use the model converter to catch element deserialization errors.
ikeough Apr 27, 2022
d9b7e8a
Skip this test due to behavior change.
ikeough Apr 27, 2022
559a35f
Fix grid tests.
ikeough Apr 29, 2022
897859b
Cleanup adaptive grid.
ikeough Apr 29, 2022
e42560d
Clean up cell complex.
ikeough Apr 29, 2022
5045bdb
Don't use JsonPropertyName unless neccessary.
ikeough Apr 29, 2022
b3d7792
Fix wall by profile test.
ikeough Apr 30, 2022
557e549
Support tuple serialization.
ikeough Apr 30, 2022
73e17b5
Fix model text tests and reenable json serialization.
ikeough Apr 30, 2022
b848643
Fix gridline.
ikeough Apr 30, 2022
07fdd75
Fix solid tests.
ikeough Apr 30, 2022
72584cf
Remove some debug statements.
ikeough Apr 30, 2022
2aaa26f
Fix parametric profile tests.
ikeough Apr 30, 2022
948714c
Use the discriminated converter.
ikeough Apr 30, 2022
2b6fde9
Include attribute no longer required.
ikeough Apr 30, 2022
032b3bb
Add field inclusion to element serialization support method.
ikeough Apr 30, 2022
31d29e1
Remove unneccessary JsonInclude.
ikeough Apr 30, 2022
677fb8f
Fix content element.
ikeough May 2, 2022
260ba9d
Fix network tests.
ikeough May 2, 2022
d1d1a2a
Don't use model converter and ignore nulls on serialize.
ikeough May 3, 2022
5c0946e
Fix ElementProxy tests.
ikeough May 4, 2022
36fca64
Merge branch 'master' into wasm-minimal
ikeough May 4, 2022
5ee367d
Add serializer options to all ToJson.
ikeough May 7, 2022
fd2afe1
Support writing public fields.
ikeough May 8, 2022
8ea5a08
Fix cell complex.
ikeough May 8, 2022
65bfd3c
Rename public fields in adaptive grid for consistency.
ikeough May 8, 2022
d6f3183
Fix dxf tests.
ikeough May 8, 2022
0492621
Cleanup.
ikeough May 8, 2022
d466b3b
Make sure we use an enum converter.
ikeough May 10, 2022
9322097
Remove last element reference to Newtonsoft.
ikeough May 10, 2022
a94e8f0
Refactor the element converter and factory into separate files.
ikeough May 10, 2022
351b8ff
Cleanup null elements, fixing last test.
ikeough May 10, 2022
0565e47
Use a slider in the test app.
ikeough May 12, 2022
c0b98ee
Merge branch 'master' into wasm-minimal
ikeough May 14, 2022
02d4cea
Use the right converter.
ikeough May 14, 2022
9db1f48
Make elements loadable from sub directory.
ikeough May 17, 2022
715db5d
Support loading from non-root locations.
ikeough May 17, 2022
eb6fae8
All specifying build type during deploy.
ikeough May 17, 2022
d1d0c1f
Fix test app to work locally.
ikeough May 21, 2022
21950f9
Remove blazor start from elements.
ikeough May 22, 2022
0b79417
Deploy to s3.
ikeough May 22, 2022
aeb303e
Cleanup.
ikeough May 22, 2022
8bdfe50
Merge branch 'master' into wasm-minimal
ikeough May 26, 2022
615d3b5
Update the syncing logic
ikeough May 28, 2022
5c35fa1
Merge branch 'master' into wasm-minimal
ikeough Jun 2, 2022
a666ce9
Merge branch 'master' into wasm-minimal
ikeough Jun 16, 2022
cd59360
Merge branch 'wasm-minimal' of https://github.com/hypar-io/Elements i…
ikeough Jun 16, 2022
57d55a2
Merge branch 'master' into wasm-minimal
ikeough Jul 8, 2022
3661f9d
Updates to used STJ.
ikeough Jul 8, 2022
246380c
Fix newly added tests.
ikeough Jul 9, 2022
0d92223
Fix for small API change.
ikeough Jul 9, 2022
e09e1d9
Leave a note on one test.
ikeough Jul 9, 2022
d22e79d
Make the element converter public.
ikeough Jul 9, 2022
e3d4455
Fix the release deploy script.
ikeough Jul 10, 2022
1b21019
Remove newtonsoft in two more places.
ikeough Jul 10, 2022
258192b
Upgrade our package references.
ikeough Jul 10, 2022
adcdbe4
Fix a typo.
ikeough Jul 10, 2022
f61e413
Increase the size of the test.
ikeough Jul 10, 2022
a00524a
Add a benchmark to simulate the API serialization.
ikeough Jul 12, 2022
5058be1
Add the geometric element converter.
ikeough Jul 12, 2022
79e8f2b
Cleanup
ikeough Jul 12, 2022
fb88cec
Don't need the converter.
ikeough Jul 13, 2022
7684f68
Don't log for render data.
ikeough Jul 13, 2022
a335be8
Don't AOT compile.
ikeough Jul 13, 2022
ba87784
Add the tower model.
ikeough Jul 13, 2022
99f6143
Convert to debug statements.
ikeough Jul 13, 2022
7f8fa20
Convert to debug statements.
ikeough Jul 13, 2022
3cd35c1
Invalidate after deploy.
ikeough Jul 13, 2022
7ee4ff2
Mode debug statements.
ikeough Jul 13, 2022
42b0f7a
Make the local example work.
ikeough Jul 13, 2022
0303dd3
Better docs on deployment.
ikeough Jul 13, 2022
680500c
Update global.json.
ikeough Jul 13, 2022
17fc1a5
Merge branch 'master' into wasm-minimal
ikeough Jul 13, 2022
a3d2ca9
Do the AOT.
ikeough Jul 16, 2022
92d1a61
Clean up deploy.
ikeough Jul 16, 2022
65085cc
Attempt graphic buffer preallocation.
ikeough Jul 17, 2022
e891889
More preallocation logic.
ikeough Jul 17, 2022
ba7ac62
Cleanup.
ikeough Jul 17, 2022
fd34890
Change the preallocation size.
ikeough Jul 17, 2022
28c2264
Merge branch 'preallocate' into wasm-preallocate
ikeough Jul 17, 2022
1479c4e
Don't run on change.
ikeough Jul 17, 2022
aa25bd3
Remove several ToArray calls.
ikeough Jul 17, 2022
cb114ed
Add some tessellation timers.
ikeough Jul 17, 2022
b978624
Format multiline text correctly.
ikeough Jul 17, 2022
9ce1cdf
Fix this method to avoid array copying.
ikeough Jul 17, 2022
e90008f
Add the hack to return items without copy.
ikeough Jul 18, 2022
6d4c91d
Add all indices to the graphics buffers at once.
ikeough Jul 18, 2022
5497a92
Bulk vertex addition to graphic buffer.
ikeough Jul 18, 2022
bd48d22
Merge branch 'wasm-minimal' of https://github.com/hypar-io/Elements i…
ikeough Jul 18, 2022
9e740f5
Convert console writes to debug writes and log.
ikeough Jul 18, 2022
5a67267
Merge branch 'master' into wasm-minimal
ikeough Aug 22, 2022
3a89bd0
Merge branch 'master' into stj
ikeough Aug 23, 2022
a141a38
One merge tweak.
ikeough Aug 23, 2022
2f7e505
some code generation tweaks and a failing test
andrewheumann Aug 24, 2022
6256fbe
bug fixes for codegen and enums
andrewheumann Aug 27, 2022
b4c5c9c
remove namedEnumConverter
andrewheumann Aug 29, 2022
0ec06b2
remove unused filter
andrewheumann Aug 29, 2022
1bdeb26
Merge pull request #876 from hypar-io/stj-ah
andrewheumann Sep 8, 2022
2ba6e1f
Merge remote-tracking branch 'origin/master' into stj
ikeough Oct 12, 2022
fffe841
Merge remote-tracking branch 'origin/master' into stj
andrewheumann Oct 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Elements.Benchmarks/API.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using BenchmarkDotNet.Attributes;
using Elements.Geometry;
using Elements.Serialization.glTF;

namespace Elements.Benchmarks
{
[MemoryDiagnoser]
public class API
{
private string _model;

[Params(5, 50, 200, 500)]
public int Value { get; set; }

[GlobalSetup]
public void Setup()
{
var model = new Model();
var r = new Random();
var size = 10;
var profile = new Profile(Polygon.L(0.1, 0.1, 0.05));
model.AddElement(profile);

for (var i = 0; i < this.Value; i++)
{
var start = new Vector3(r.NextDouble() * size, r.NextDouble() * size, r.NextDouble() * size);
var end = new Vector3(r.NextDouble() * size, r.NextDouble() * size, r.NextDouble() * size);
var line = new Line(start, end);
// var c = new Color(r.NextDouble(), r.NextDouble(), r.NextDouble(), 1.0);
// var m = new Material(Guid.NewGuid().ToString(), c);
var beam = new Beam(line, profile, null, BuiltInMaterials.Steel);
model.AddElement(beam);
}

_model = model.ToJson();
}

[Benchmark(Description = "API Test Serialization")]
public void SerializeElementsToGlTF()
{
Model.GeometricElementModelFromJson(_model);
}
}
}
2 changes: 1 addition & 1 deletion Elements.CodeGeneration/src/Templates/Catalog.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Elements.Geometry;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Elements {
public static class {{ catalog.name | safeidentifierupper }} {
Expand Down
7 changes: 2 additions & 5 deletions Elements.CodeGeneration/src/Templates/Class.liquid
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{% if HasDescription -%}
/// <summary>{{ Description | csharpdocs }}</summary>
{% endif -%}
{% if HasDiscriminator -%}
[JsonConverter(typeof(Elements.Serialization.JSON.JsonInheritanceConverter), "{{ Discriminator }}")]
{% endif -%}
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "{{ ToolchainVersion }}")]
{% if InheritsExceptionSchema -%}
[JsonObjectAttribute]
Expand All @@ -30,7 +27,7 @@
{% if property.HasDescription -%}
/// <summary>{{ property.Description | csharpdocs }}</summary>
{% endif -%}
[JsonProperty("{{ property.Name }}", Required = {{ property.JsonPropertyRequiredCode }}{% if property.IsStringEnumArray %}, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter){% endif %})]
[JsonPropertyName("{{ property.Name }}")]
{% if property.RenderRequiredAttribute -%}
[System.ComponentModel.DataAnnotations.Required{% if property.AllowEmptyStrings %}(AllowEmptyStrings = true){% endif %}]
{% endif -%}
Expand All @@ -50,7 +47,7 @@
[System.ComponentModel.DataAnnotations.RegularExpression(@"{{ property.RegularExpressionValue }}")]
{% endif -%}
{% if property.IsStringEnum -%}
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
{% endif -%}
{% if property.IsDate and UseDateFormatConverter -%}
[JsonConverter(typeof(DateFormatConverter))]
Expand Down
2 changes: 1 addition & 1 deletion Elements.CodeGeneration/src/Templates/File.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Elements.Geometry.Solids;
using Elements.Spatial;
using Elements.Validators;
using Elements.Serialization.JSON;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion Elements.CodeGeneration/src/TypeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
using NJsonSchema;
using NJsonSchema.CodeGeneration.CSharp;
using Elements.Generate.StringUtils;
Expand Down
2 changes: 1 addition & 1 deletion Elements.Components/src/ComponentDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using Elements;
using Elements.Geometry;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Elements.Components
{
Expand Down
2 changes: 1 addition & 1 deletion Elements.Components/src/ContentCatalogRetrieval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Reflection;
using Elements.Geometry;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Elements.Components
{
Expand Down
2 changes: 1 addition & 1 deletion Elements.Components/src/Rules/SizeBasedPlacementRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Elements.Geometry;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Elements.Components
{
Expand Down
5 changes: 2 additions & 3 deletions Elements.Components/src/SpaceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Elements;
using Elements.Components;
using System.Text.Json.Serialization;
using Elements.Geometry;

namespace Elements.Components
Expand Down Expand Up @@ -99,7 +98,7 @@ private ContentElement MakeContentElement()
/// <summary>
/// The content element corresponding to this item.
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[JsonIgnore]
public ContentElement ContentElement
{
get
Expand Down
9 changes: 5 additions & 4 deletions Elements.Playground/Elements.Playground.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<BlazorEnableCompression>false</BlazorEnableCompression>
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
<PublishTrimmed>false</PublishTrimmed>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.11.0" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
63 changes: 35 additions & 28 deletions Elements.Playground/Pages/Model.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
@using Microsoft.CodeAnalysis
@using Microsoft.CodeAnalysis.CSharp
@using Microsoft.CodeAnalysis.CSharp.Scripting.Hosting
@using System.Diagnostics
@using System.Reflection
@using System.IO
@using System.Threading
@using System.Web
@using System.Diagnostics

@inject IJSRuntime JSRuntime
@inject IJSUnmarshalledRuntime JSUnmarshalledRuntime
@inject NavigationManager MyNavigationManager

@using System.Text.RegularExpressions;
<div class="grid">
<button class="run" disabled=@loading @onclick="Run">Run</button>
<div id="editor">@csharp</div>
<div id="model"></div>
<div class="output">@((MarkupString)Output)</div>
<div class="output">@((MarkupString)Regex.Replace(
HttpUtility.HtmlEncode(@Output), "\r?\n|\r", "<br />"))</div>
</div>

@code {
Expand All @@ -32,35 +35,35 @@ var p = wf.GetProfileByType(WideFlangeProfileType.W10x100);

for(var i=0; i<1; i++)
{
var start = new Vector3(i, 0, 0);
var end = new Vector3(i, length, i);
var start = new Vector3(i, 0, 0);
var end = new Vector3(i, length, i);

// The bottom chord
var bottomChord = new Line(start, end);
var bottomChordBeam = new Beam(bottomChord, p, m);
model.AddElement(bottomChordBeam);
// The bottom chord
var bottomChord = new Line(start, end);
var bottomChordBeam = new Beam(bottomChord, p, null, m);
model.AddElement(bottomChordBeam);

var topChord = new Line(start + new Vector3(0,0,5), end + new Vector3(0,0,5));
var topChordBeam = new Beam(topChord, p, m);
model.AddElement(topChordBeam);
var topChord = new Line(start + new Vector3(0,0,5), end + new Vector3(0,0,5));
var topChordBeam = new Beam(topChord, p, null, m);
model.AddElement(topChordBeam);

Vector3 last = default(Vector3);
for(var j=0.0; j<=1.0; j+=0.1)
{
var pt = bottomChord.PointAt(j);
var top = pt + new Vector3(0,0,5);
var panelLine = new Line(pt, top);
var panelBeam = new Beam(panelLine, p, m);
model.AddElement(panelBeam);
Vector3 last = default(Vector3);
for(var j=0.0; j<=1.0; j+=0.1)
{
var pt = bottomChord.PointAt(j);
var top = pt + new Vector3(0,0,5);
var panelLine = new Line(pt, top);
var panelBeam = new Beam(panelLine, p, null, m);
model.AddElement(panelBeam);

if(j > 0.0)
{
var braceLine = new Line(top, last);
var braceBeam = new Beam(braceLine, p, m);
model.AddElement(braceBeam);
}
last = pt;
}
if(j > 0.0)
{
var braceLine = new Line(top, last);
var braceBeam = new Beam(braceLine, p, null, m);
model.AddElement(braceBeam);
}
last = pt;
}
}
return model;";
private static string Output = "";
Expand Down Expand Up @@ -115,6 +118,11 @@ return model;";
var writer = new StringWriter();
Console.SetOut(writer);

// Redirect debug to the console.
Trace.Listeners.Clear();
Trace.Listeners.Add(
new TextWriterTraceListener(Console.Out));

Exception exception = null;
try
{
Expand Down Expand Up @@ -143,7 +151,6 @@ return model;";
Output = writer.ToString();
if (exception != null)
{

Output += "\r\n" + exception.ToString();
}
Console.SetOut(currentOut);
Expand Down
2 changes: 1 addition & 1 deletion Elements.Playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a minimal example using .NET 5, Blazor webassembly, and Elements.
Visit http://localhost:5000.

### Publishing
`dotnet public -c release`
`dotnet publish -c release`

### Notes about hosting on Github Pages
- In the site's repo on github
Expand Down
9 changes: 0 additions & 9 deletions Elements.Playground/wwwroot/js/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,9 @@ function initializeEditor() {
enableLiveAutocompletion: true
});

let timer;
let runTimer = () => {
timer = setTimeout(() => {
invokeRun();
}, 2000);
}

editor.getSession().on('change', function () {
var code = editor.getValue();
DotNet.invokeMethod('Elements.Playground', 'SetCodeValue', code)
clearTimeout(timer);
runTimer();
});
}

Expand Down
3 changes: 2 additions & 1 deletion Elements.Serialization.DXF/tests/DxfTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using Elements.Geometry;
using Xunit;

Expand Down Expand Up @@ -67,7 +68,7 @@ public void DxfFromModel()
var renderer = new DXF.ModelToDxf();

var configJson = File.ReadAllText("../../../TestModels/cad-standard.json");
var config = Newtonsoft.Json.JsonConvert.DeserializeObject<MappingConfiguration>(configJson);
var config = JsonSerializer.Deserialize<MappingConfiguration>(configJson);
renderer.SetMappingConfiguration(config);
var stream = renderer.Render(model);
stream.Position = 0;
Expand Down
2 changes: 1 addition & 1 deletion Elements.Serialization.SVG/test/SvgTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class SvgTests
public void Plan()
{
var json = File.ReadAllText("../../../models/tower.json");
var model = Model.FromJson(json, out _);
var model = Model.FromJson(json);

model.UpdateRepresentations();
model.UpdateBoundsAndComputedSolids();
Expand Down
1 change: 1 addition & 0 deletions Elements.Wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deploy
22 changes: 22 additions & 0 deletions Elements.Wasm/Elements.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<RunAOTCompilation>true</RunAOTCompilation>
<!-- Don't cache boot resources to avoid checksum failures for re-bundled files. -->
<BlazorCacheBootResources>false</BlazorCacheBootResources>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elements\src\Elements.csproj" />
</ItemGroup>

</Project>
Loading