Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions serialize-linq/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
5 changes: 5 additions & 0 deletions serialize-linq/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
*.sln.iml
.idea/**/*
**/.idea/*
22 changes: 22 additions & 0 deletions serialize-linq/Apps/HelloApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//namespace SerializeLinq.Apps;

//[App(icon:Icons.PartyPopper, title:"Hello")]
//public class HelloApp : ViewBase
//{
// public override object? Build()
// {
// var nameState = this.UseState<string>();

// return Layout.Center()
// | (new Card(
// Layout.Vertical().Gap(6).Padding(2)
// | new Confetti(new IvyLogo())
// | Text.H2("Hello " + (string.IsNullOrEmpty(nameState.Value) ? "there" : nameState.Value) + "!")
// | Text.Block("Welcome to the fantastic world of Ivy. Let's build something amazing together!")
// | nameState.ToInput(placeholder: "What is your name?")
// | new Separator()
// | Text.Markdown("You'd be a hero to us if you could ⭐ us on [Github](https://github.com/Ivy-Interactive/Ivy-Framework)")
// )
// .Width(Size.Units(120).Max(500)));
// }
//}
89 changes: 89 additions & 0 deletions serialize-linq/Apps/SerializeLinqApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Serialize.Linq.Serializers;
using System.Linq.Expressions;

namespace SerializeLinq.Apps;

[App(icon: Icons.Pencil, title: "Serialize Linq")]
public class SerializeLinqApp : ViewBase
{
public override object? Build()
{
//Input states
var value1State = this.UseState<int>();
var value2State = this.UseState<int>();
var operatorState = this.UseState<string>();

//Serialization state
var jsonState = this.UseState<string>();

//Deserialization states
var expressionState = this.UseState<string>();
var comparisonResultState = this.UseState<string>();

return Layout.Vertical()
| Text.Block("Hello world!")
//Inputs
| (Layout.Horizontal()
| value1State.ToNumberInput().Width(Size.Grow())
| operatorState.ToSelectInput(new string[] { "=", "<", "<=", ">", ">=", "!=" }.ToOptions()).Width(Size.Third())
| value2State.ToNumberInput().Width(Size.Grow()))
//Serialize button
| new Button("Serialize", () =>
{
Expression<Func<int, bool>> expression = null;

Copilot AI Oct 7, 2025

Copy link

Choose a reason for hiding this comment

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

Initializing reference types to null is unnecessary in C#. The variable can be declared without initialization since it's assigned in all switch cases.

Suggested change
Expression<Func<int, bool>> expression = null;
Expression<Func<int, bool>> expression;

Copilot uses AI. Check for mistakes.
switch (operatorState.Value)
{
case "=":
expression = val => value1State.Value == val;
break;
case "<":
expression = val => value1State.Value < val;
break;
case "<=":
expression = val => value1State.Value <= val;
break;
case ">":
expression = val => value1State.Value > val;
break;
case ">=":
expression = val => value1State.Value >= val;
break;
case "!=":
expression = val => value1State.Value != val;
break;
}
if (expression != null)
{
var serializer = new ExpressionSerializer(new JsonSerializer());

//The result is a json representation of the expression
jsonState.Set(serializer.SerializeText(expression));
}
else
{
jsonState.Set("Invalid expression");
}
})
//Serialization result
| Text.Block(jsonState)
//Deserialize button (only works with serialization result, works like a validation for the json result)
| new Button("Deserialize Result", () =>
{
try
{
var serializer = new ExpressionSerializer(new JsonSerializer());
Expression<Func<int, bool>> expression = (Expression<Func<int, bool>>)serializer.DeserializeText(jsonState.Value);

//Expression definition (value1 + operator)
expressionState.Set($"Expression: {expression}");

//Result of the expresion when using value2
comparisonResultState.Set($"The comparison is {expression.Compile()(value2State.Value).ToString().ToLower()}");
}
catch { }

Copilot AI Oct 7, 2025

Copy link

Choose a reason for hiding this comment

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

Empty catch block silently swallows exceptions. Consider logging the exception or providing user feedback when deserialization fails.

Suggested change
catch { }
catch (Exception ex)
{
// Log the exception for diagnostics
Console.WriteLine($"Deserialization failed: {ex.Message}");
// Provide user feedback
expressionState.Set("Deserialization failed.");
comparisonResultState.Set("");
}

Copilot uses AI. Check for mistakes.
})
//Deserialization results
| Text.Block(expressionState.Value)
| Text.Block(comparisonResultState);
}
}
34 changes: 34 additions & 0 deletions serialize-linq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Base runtime image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80

# Build stage
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

# Copy and restore
COPY ["SerializeLinq.csproj", "./"]
RUN dotnet restore "SerializeLinq.csproj"

# Copy everything and build
COPY . .
RUN dotnet build "SerializeLinq.csproj" -c $BUILD_CONFIGURATION -o /app/build

# Publish stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "SerializeLinq.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true

# Final runtime image
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

# Set environment variables
ENV PORT=80
ENV ASPNETCORE_URLS="http://+:80"

# Run the executable
ENTRYPOINT ["dotnet","./SerializeLinq.dll"]
28 changes: 28 additions & 0 deletions serialize-linq/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
global using Ivy;
global using Ivy.Apps;
global using Ivy.Auth;
global using Ivy.Chrome;
global using Ivy.Client;
global using Ivy.Core;
global using Ivy.Core.Hooks;
global using Ivy.Helpers;
global using Ivy.Hooks;
global using Ivy.Shared;
global using Ivy.Views;
global using Ivy.Views.Alerts;
global using Ivy.Views.Blades;
global using Ivy.Views.Builders;
global using Ivy.Views.Charts;
global using Ivy.Views.Dashboards;
global using Ivy.Views.Forms;
global using Ivy.Views.Tables;
global using Ivy.Widgets.Inputs;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Logging;
global using System.Collections.Immutable;
global using System.ComponentModel.DataAnnotations;
global using System.Globalization;
global using System.Reactive.Linq;

namespace SerializeLinq;
11 changes: 11 additions & 0 deletions serialize-linq/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using SerializeLinq.Apps;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");
var server = new Server();
#if DEBUG
server.UseHotReload();
#endif
server.AddAppsFromAssembly();
server.AddConnectionsFromAssembly();
var chromeSettings = new ChromeSettings().DefaultApp<SerializeLinqApp>().UseTabs(preventDuplicates: true);
server.UseChrome(chromeSettings);
await server.RunAsync();
17 changes: 17 additions & 0 deletions serialize-linq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Hello

Web application created using [Ivy](https://github.com/Ivy-Interactive/Ivy).

Ivy is a web framework for building interactive web applications using C# and .NET.

## Run

```
dotnet watch
```

## Deploy

```
ivy deploy
```
23 changes: 23 additions & 0 deletions serialize-linq/SerializeLinq.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>CS8618;CS8603;CS8602;CS8604;CS9113</NoWarn>
<RootNamespace>SerializeLinq</RootNamespace>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Assets/**/*" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ivy" Version="1.*" />
<PackageReference Include="Serialize.Linq" Version="4.0.167" />
</ItemGroup>
<ItemGroup>
<Folder Include="Connections" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions serialize-linq/SerializeLinq.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello", "SerializeLinq.csproj", "{039638F3-A6D7-FB67-E733-27BD896EFDC4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{039638F3-A6D7-FB67-E733-27BD896EFDC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{039638F3-A6D7-FB67-E733-27BD896EFDC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{039638F3-A6D7-FB67-E733-27BD896EFDC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{039638F3-A6D7-FB67-E733-27BD896EFDC4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5F74B1AD-6C2E-4FDA-9DAF-9F7D8053687B}
EndGlobalSection
EndGlobal
Loading