Skip to content

Commit

Permalink
Merge branch 'main' of github.com:riganti/dotvvm into feature/azure-p…
Browse files Browse the repository at this point in the history
…ipelines
  • Loading branch information
cafour committed Jul 15, 2021
2 parents e3f4aef + 672d9f5 commit 744b4fa
Show file tree
Hide file tree
Showing 43 changed files with 1,541 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -90,7 +90,7 @@ There is also [dotnet new template](https://www.dotvvm.com/docs/tutorials/how-to

| | ASP.NET Core | OWIN |
|-------------------------|-----------------------------|-----------------------|
| Current stable version | `DotVVM.AspNetCore 3.0.4` | `DotVVM.Owin 3.0.4` |
| Current stable version | `DotVVM.AspNetCore 3.1.0` | `DotVVM.Owin 3.1.0` |
| Minimum runtime version | `.NET Core 2.1` | `.NET 4.5.1` |
| Minimum ASP.NET version | `ASP.NET Core 2.1` | `OWIN 3.0.1` |

Expand Down
6 changes: 3 additions & 3 deletions contributing.md
Expand Up @@ -20,7 +20,7 @@ First, start by choosing what you'd like to do - you can have a look at [issues

Then, you can fork the repo, clone it locally, and you are ready to develop.

Finally, you'll need to create a pull request to the `v3-master` (for DotVVM 3.0) or `master` branch (for DotVVM 2.5) (__we can help with that__), make sure that you have merged the latest changes and that the PR has a readable diff.
Finally, you'll need to create a pull request to the `v4-main` (for DotVVM 4.0) or `main` branch (for DotVVM 3.x) (__we can help with that__), make sure that you have merged the latest changes and that the PR has a readable diff.

**Please avoid reformatting documents, refactoring stuff, changing CRLF to LF or tabs to spaces etc. - it makes the PRs difficult to review.** There is definitely room for refactoring or cleanup, but it should be done in a separate PR so it is not messed up with functional changes.

Expand All @@ -44,13 +44,13 @@ If you plan to work with the DotVVM repository, here is a short manual what you

To get started, fork the repository, and clone it on or computer. You can use Visual Studio's Team Explorer window or run `git clone https://github.com/<your_github_username>/dotvvm.git`.

We are using Visual Studio 2019 or Visual Studio Code. Some projects use .NET Core 2.0 and .NET Core 3.1, so the solution will probably not open in previous versions of Visual Studio.
We are using Visual Studio 2019 or Visual Studio Code. Some projects use .NET Core 2.1, 3.1 and .NET 5.0, so the solution will probably not open in older versions of Visual Studio.

Open the `src/DotVVM.sln` solution in Visual Studio, or open the `src` folder in VS Code.

Set `Samples/DotVVM.Samples.BasicSamples.AspNetCore` as a startup project and launch it. It should just work - you'll see a page with a long list of samples (they are not often meaningful, they are used by the UI tests to verify all framework features work; however they are great for playing).

If the project does not start, feel free to ask us on [Gitter](https://gitter.im/riganti/dotvvm). For VS Code, launch it from the `src` directory, so it can find the `.vscode/launch.json` and `.vscode/tasks.json` files. You can also try to rebuild `Tests/DotVVM.Framework.Tests.Common` project and run the unit/integration tests - it should complete in few seconds, everything should be green. :)
If the project does not start, feel free to ask us on [Gitter](https://gitter.im/riganti/dotvvm). For VS Code, launch it from the `src` directory, so it can find the `.vscode/launch.json` and `.vscode/tasks.json` files. You can also try to rebuild `Tests/DotVVM.Framework.Tests` project and run the unit/integration tests - it should complete in few seconds, everything should be green. :)

Almost everying interesting is in the `DotVVM.Framework` project, except for some base interfaces and attributes in `DotVVM.Core` (so you don't have to reference the entire framework in your bussiess layer, if you just want to suppress serialization or turn on the validation of certain properties).

Expand Down
4 changes: 2 additions & 2 deletions src/DotVVM.CommandLine/DotVVM.CommandLine.csproj
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyTitle>DotVVM.CommandLine</AssemblyTitle>
<AssemblyName>dotnet-dotvvm</AssemblyName>
<VersionPrefix>3.1.0-preview06-final</VersionPrefix>
<VersionPrefix>3.1.0</VersionPrefix>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyOriginatorKeyFile>dotvvmwizard.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -21,7 +21,7 @@
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>DotVVM.CommandLine</PackageId>
<PackageVersion>3.1.0-preview06-final</PackageVersion>
<PackageVersion>3.1.0</PackageVersion>
<Authors>RIGANTI</Authors>
<Description>Command-line tools for DotVVM.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
4 changes: 2 additions & 2 deletions src/DotVVM.Core/DotVVM.Core.csproj
@@ -1,6 +1,6 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>3.1.0-preview06-final</VersionPrefix>
<VersionPrefix>3.1.0</VersionPrefix>
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -17,7 +17,7 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<PackageId>DotVVM.Core</PackageId>
<PackageVersion>3.1.0-preview06-final</PackageVersion>
<PackageVersion>3.1.0</PackageVersion>
<Authors>RIGANTI</Authors>
<Description>This package contains base classes and interfaces of DotVVM that might be useful in a business layer.
DotVVM is an open source ASP.NET-based framework which allows to build modern web apps without writing any JavaScript code.</Description>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>DotVVM.Api.Swashbuckle.AspNetCore</PackageId>
<PackageVersion>3.1.0-preview06-final</PackageVersion>
<PackageVersion>3.1.0</PackageVersion>
<Authors>RIGANTI</Authors>
<Description>Swashbuckle.AspNetCore extensions for DotVVM.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<PackageId>DotVVM.Api.Swashbuckle.Owin</PackageId>
<PackageVersion>3.1.0-preview06-final</PackageVersion>
<PackageVersion>3.1.0</PackageVersion>
<Authors>RIGANTI</Authors>
<Description>Swashbuckle.Owin extensions for DotVVM.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
@@ -1,6 +1,6 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>3.1.0-preview06-final</VersionPrefix>
<VersionPrefix>3.1.0</VersionPrefix>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -17,7 +17,7 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<PackageId>DotVVM.AspNetCore</PackageId>
<PackageVersion>3.1.0-preview06-final</PackageVersion>
<PackageVersion>3.1.0</PackageVersion>
<Authors>RIGANTI</Authors>
<Description>
This package contains ASP.NET Core middleware and hosting infrastructure for DotVVM apps. It supports both .NET Framework and .NET Core.
Expand Down
@@ -1,6 +1,6 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>3.1.0-preview06-final</VersionPrefix>
<VersionPrefix>3.1.0</VersionPrefix>
<TargetFramework>net451</TargetFramework>
<RuntimeIdentifiers>win7-x64;win7-x86</RuntimeIdentifiers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -17,7 +17,7 @@
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<PackageId>DotVVM.Owin</PackageId>
<PackageVersion>3.1.0-preview06-final</PackageVersion>
<PackageVersion>3.1.0</PackageVersion>
<Authors>RIGANTI</Authors>
<Description>
This package contains OWIN middleware and hosting infrastructure for DotVVM apps.
Expand Down
37 changes: 36 additions & 1 deletion src/DotVVM.Framework.Tests/Binding/BindingCompilationTests.cs
Expand Up @@ -345,7 +345,6 @@ public void BindingCompiler_Invalid_LambdaParameters(string expr)
[TestMethod]
[DataRow("(TestViewModel vm) => vm.IntProp = 11")]
[DataRow("(TestViewModel vm) => vm.GetEnum()")]
[DataRow("(TestViewModel vm) => ()")]
[DataRow("(TestViewModel vm) => ;")]
public void BindingCompiler_Valid_LambdaToAction(string expr)
{
Expand Down Expand Up @@ -783,6 +782,38 @@ public void BindingCompiler_DictionaryIndexer_Set()
Assert.AreEqual(123, vm.Dictionary[1]);
}

[TestMethod]
public void BindingCompiler_ListIndexer_Get()
{
TestViewModel5 vm = new TestViewModel5();
var result = ExecuteBinding("List[1]", new[] { vm });
Assert.AreEqual(2, result);
}

[TestMethod]
public void BindingCompiler_ListIndexer_Set()
{
TestViewModel5 vm = new TestViewModel5();
ExecuteBinding("List[1] = 111", new[] { vm }, null, expectedType: typeof(void));
Assert.AreEqual(111, vm.List[1]);
}

[TestMethod]
public void BindingCompiler_ArrayElement_Get()
{
TestViewModel5 vm = new TestViewModel5();
var result = ExecuteBinding("Array[1]", new[] { vm });
Assert.AreEqual(2, result);
}

[TestMethod]
public void BindingCompiler_ArrayElement_Set()
{
TestViewModel5 vm = new TestViewModel5();
ExecuteBinding("Array[1] = 111", new[] { vm }, null, expectedType: typeof(void));
Assert.AreEqual(111, vm.Array[1]);
}

[TestMethod]
public void BindingCompiler_MultiBlockExpression_EnumAtEnd_CorrectResult()
{
Expand Down Expand Up @@ -912,6 +943,7 @@ class TestViewModel
public TestViewModel2 TestViewModel2B { get; set; }
public TestEnum EnumProperty { get; set; }
public string StringProp2 { get; set; }
public DateTime DateTime { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public object Time { get; set; } = TimeSpan.FromSeconds(5);
Expand Down Expand Up @@ -1041,6 +1073,9 @@ class TestViewModel5
{ 2, 22 },
{ 3, 33 }
};

public List<int> List { get; set; } = new List<int>() { 1, 2, 3 };
public int[] Array { get; set; } = new int[] { 1, 2, 3 };
}

struct TestStruct
Expand Down
60 changes: 58 additions & 2 deletions src/DotVVM.Framework.Tests/Binding/JavascriptCompilationTests.cs
Expand Up @@ -385,6 +385,34 @@ public void JsTranslator_ArrayIndexer()
Assert.AreEqual("LongArray()[1]()==3&&(VmArray()[0]().MyProperty()==1&&VmArray().length>1)", result);
}

[TestMethod]
public void JsTranslator_ArrayElement_Get()
{
var result = CompileBinding("Array[1]", typeof(TestViewModel5));
Assert.AreEqual("Array()[1]", result);
}

[TestMethod]
public void JsTranslator_ArrayElement_Set()
{
var result = CompileBinding("Array[1] = 123", new[] { typeof(TestViewModel5) }, typeof(void));
Assert.AreEqual("dotvvm.translations.array.setItem(Array,1,123)", result);
}

[TestMethod]
public void JsTranslator_ListIndexer_Get()
{
var result = CompileBinding("List[1]", typeof(TestViewModel5));
Assert.AreEqual("List()[1]", result);
}

[TestMethod]
public void JsTranslator_ListIndexer_Set()
{
var result = CompileBinding("List[1] = 123", new[] { typeof(TestViewModel5) }, typeof(void));
Assert.AreEqual("dotvvm.translations.array.setItem(List,1,123)", result);
}

[TestMethod]
public void JsTranslator_DictionaryIndexer_Get()
{
Expand Down Expand Up @@ -828,7 +856,7 @@ public void JsTranslator_StringSplit_ArrayDelimiters_NoOptions(string binding, s
public void JsTranslator_StringArrayJoin(string binding, string delimiter)
{
var result = CompileBinding(binding, new[] { typeof(TestViewModel) });
Assert.AreEqual($"StringArray().join(\"{delimiter}\")", result);
Assert.AreEqual($"dotvvm.translations.string.join(StringArray(),\"{delimiter}\")", result);
}

[TestMethod]
Expand All @@ -837,7 +865,7 @@ public void JsTranslator_StringArrayJoin(string binding, string delimiter)
public void JsTranslator_StringEnumerableJoin(string binding, string delimiter)
{
var result = CompileBinding(binding, new[] { new NamespaceImport("System.Linq") }, new[] { typeof(TestViewModel) });
Assert.AreEqual($"StringArray().filter(function(item){{return ko.unwrap(item).length>2;}}).join(\"{delimiter}\")", result);
Assert.AreEqual($"dotvvm.translations.string.join(StringArray().filter(function(item){{return ko.unwrap(item).length>2;}}),\"{delimiter}\")", result);
}

[TestMethod]
Expand All @@ -849,6 +877,34 @@ public void JsTranslator_StringReplace(string binding, string original, string r
Assert.AreEqual($"StringProp().split(\"{original}\").join(\"{replacement}\")", result);
}

[TestMethod]
[DataRow("DateTime.Year", "getFullYear", false)]
[DataRow("DateTime.Month", "getMonth", true)]
[DataRow("DateTime.Day", "getDate", false)]
[DataRow("DateTime.Hour", "getHours", false)]
[DataRow("DateTime.Minute", "getMinutes", false)]
[DataRow("DateTime.Second", "getSeconds", false)]
[DataRow("DateTime.Millisecond", "getMilliseconds", false)]
public void JsTranslator_DateTime_Property_Getters(string binding, string jsFunction, bool increment = false)
{
var result = CompileBinding(binding, new[] { typeof(TestViewModel) });
Assert.AreEqual($"new Date(DateTime()).{jsFunction}(){(increment ? "+1" : string.Empty)}", result);
}

[TestMethod]
public void JsTranslator_WebUtility_UrlEncode()
{
var result = CompileBinding("WebUtility.UrlEncode(\"Hello World!\")", new[] { new NamespaceImport("System.Net") }, new[] { typeof(TestViewModel) });
Assert.AreEqual($"encodeURIComponent(\"Hello World!\")", result);
}

[TestMethod]
public void JsTranslator_WebUtility_UrlDecode()
{
var result = CompileBinding("WebUtility.UrlDecode(\"Hello%20World!\")", new[] { new NamespaceImport("System.Net") }, new[] { typeof(TestViewModel) });
Assert.AreEqual($"decodeURIComponent(\"Hello%20World!\")", result);
}

[TestMethod]
public void JavascriptCompilation_GuidToString()
{
Expand Down
Expand Up @@ -227,11 +227,22 @@ protected override Expression VisitBinaryOperator(BinaryOperatorBindingParserNod
var right = HandleErrors(node.SecondExpression, Visit);
ThrowOnErrors();

if (eop == ExpressionType.Assign && left is IndexExpression indexExpression)
if (eop == ExpressionType.Assign)
{
// Convert to explicit method call `set_{Indexer}(index, value)`
var setMethod = indexExpression.Indexer.SetMethod;
return Expression.Call(indexExpression.Object, setMethod, indexExpression.Arguments.Concat(new[] { right }));
if (left is IndexExpression indexExpression)
{
// Convert to explicit method call `set_{Indexer}(index, value)`
var setMethod = indexExpression.Indexer.SetMethod;
return Expression.Call(indexExpression.Object, setMethod, indexExpression.Arguments.Concat(new[] { right }));
}
else if (left is BinaryExpression arrayIndexExpression && left.NodeType == ExpressionType.ArrayIndex)
{
// Convert to explicit method call `Array.SetValue(value, index)`
var setMethod = typeof(Array).GetMethod(nameof(Array.SetValue), BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(object), typeof(int) }, null);
// If we are working with array of value types then box the value
var value = (right != null && right.Type.IsValueType) ? Expression.TypeAs(right, typeof(object)) : right;
return Expression.Call(arrayIndexExpression.Left, setMethod, new[] { value /* value */, arrayIndexExpression.Right /* index */ });
}
}

return memberExpressionFactory.GetBinaryOperator(left, right, eop);
Expand Down
4 changes: 3 additions & 1 deletion src/DotVVM.Framework/Compilation/CompiledAssemblyCache.cs
Expand Up @@ -68,10 +68,12 @@ internal static IEnumerable<Assembly> BuildReferencedAssembliesCache(DotvvmConfi
typeof(DotvvmConfiguration).Assembly,
#if DotNetCore
Assembly.Load(new AssemblyName("System.Runtime")),
Assembly.Load(new AssemblyName("System.Private.CoreLib")),
Assembly.Load(new AssemblyName("System.Collections.Concurrent")),
Assembly.Load(new AssemblyName("System.Collections")),
#else
typeof(List<>).Assembly
typeof(List<>).Assembly,
typeof(System.Net.WebUtility).Assembly
#endif
});

Expand Down

0 comments on commit 744b4fa

Please sign in to comment.