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

Added support for net8.0 #18

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
- name: Build Nuget Package
run: dotnet pack -c Release azure-documentdb-odata-sql\azure-documentdb-odata-sql.csproj -o . /p:NuspecFile=azure-documentdb-odata-sql.nuspec /p:Version=${{needs.versioning.outputs.version}} /p:NuspecProperties="version=${{needs.versioning.outputs.version}}" /p:PackageID=Lambda.Azure.CosmosDb.OData.Sql
- name: Push NuGet Package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
- name: Build project
run: dotnet build azure-documentdb-odata-sql.sln
- name: Run tests
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ For example:


## Release Notes
* 5.0.x
* No logic change
* Added support for .Net 8
* 4.2.x
* Fixed an issue with `any` not being detected correctly
* 4.1.x
Expand Down
43 changes: 27 additions & 16 deletions azure-documentdb-odata-sql-samples/ODataToSqlSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Builder;

#if NET6_0
#if NET6_0 || NET8_0
using Microsoft.AspNetCore.OData;
using Microsoft.AspNetCore.OData.Query.Validator;
using Microsoft.OData.ModelBuilder;
Expand Down Expand Up @@ -56,9 +56,9 @@ public static void ClassInitialize(TestContext testContext)

var collection = new ServiceCollection();

#if NET6_0
collection
.AddControllers()
#if NET6_0 || NET8_0
collection
.AddControllers()
.AddOData();
#else
collection.AddOData();
Expand All @@ -72,23 +72,23 @@ public static void ClassInitialize(TestContext testContext)
collection.AddTransient<SkipQueryValidator>();
collection.AddTransient<OrderByQueryValidator>();

#if NET6_0
collection.AddTransient<ILoggerFactory, TestLoggingFactory>();
#if NET6_0 || NET8_0
collection.AddTransient<ILoggerFactory, TestLoggingFactory>();
#endif

Provider = collection.BuildServiceProvider();

var applicationBuilder = Substitute.For<IApplicationBuilder>();
applicationBuilder.ApplicationServices.Returns(Provider);

#if !NET6_0
#if !NET6_0 && !NET8_0
var routeBuilder = new RouteBuilder(applicationBuilder);
routeBuilder.EnableDependencyInjection();
#endif
}
}

// Use TestInitialize to run code before running each test
[TestInitialize()]
// Use TestInitialize to run code before running each test
[TestInitialize()]
public void TestInitialize()
{
HttpRequest = new DefaultHttpRequest(new DefaultHttpContext
Expand Down Expand Up @@ -637,8 +637,12 @@ public void TranslateAnyToJoin_WhenThereIsOneNestedjoinWithComplexPath()

var oDataToSqlTranslator = new ODataToSqlTranslator(new SQLQueryFormatter());
var sqlQuery = oDataToSqlTranslator.Translate(oDataQueryOptions, TranslateOptions.ALL & ~TranslateOptions.TOP_CLAUSE);
Assert.AreEqual("SELECT VALUE c FROM c JOIN l IN c.payload.bet.legs JOIN o IN l.outcomes WHERE o.id = 'test' ", sqlQuery);
}
#if NET8_0
Assert.AreEqual("SELECT VALUE c FROM c JOIN l IN c.payload.bet.legs JOIN o IN l.legs.outcomes WHERE o.id = 'test' ", sqlQuery);
#else
Assert.AreEqual("SELECT VALUE c FROM c JOIN l IN c.payload.bet.legs JOIN o IN l.outcomes WHERE o.id = 'test' ", sqlQuery);
#endif
}

[TestMethod]
public void TranslateEnum_WhenClassDoestHaveId()
Expand Down Expand Up @@ -755,10 +759,17 @@ public void TranslateAnyToJoin_WhenThereIsOneNestedjoinAndConditionBasedOnChildP

var sqlQuery =
oDataToSqlTranslator.Translate(oDataQueryOptions, TranslateOptions.ALL & ~TranslateOptions.TOP_CLAUSE);
Assert.AreEqual(

#if NET8_0
Assert.AreEqual(
"SELECT VALUE c FROM c JOIN l IN c.payload.bet.legs JOIN o IN l.legs.outcomes WHERE o.competitor.id = 'test' ",
sqlQuery);
#else
Assert.AreEqual(
"SELECT VALUE c FROM c JOIN l IN c.payload.bet.legs JOIN o IN l.outcomes WHERE o.competitor.id = 'test' ",
sqlQuery);
}
#endif
}

[TestMethod]
public void TranslateAnyToJoin_ReturnsCorrectResult_WhenQueryIsBasedOnANestedProperty()
Expand Down Expand Up @@ -880,8 +891,8 @@ private static ODataQueryOptions GetODataQueryOptions(string oData)
#endregion
}

#if NET6_0
public class TestLoggingFactory : Microsoft.Extensions.Logging.ILoggerFactory
#if NET6_0 || NET8_0
public class TestLoggingFactory : Microsoft.Extensions.Logging.ILoggerFactory
{
private readonly ILogger logger = Substitute.For<ILogger>();
public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net6.0;net8.0</TargetFrameworks>
<debugType>full</debugType>
</PropertyGroup>

Expand Down Expand Up @@ -30,7 +30,16 @@
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
</ItemGroup>


<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\azure-documentdb-odata-sql\Azure-Documentdb-OData-Sql.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Microsoft.AspNet.OData.Query;
#endif

#if NET6_0
#if NET6_0 || NET8_0
using Microsoft.AspNetCore.OData.Query;
#endif

Expand Down
7 changes: 6 additions & 1 deletion azure-documentdb-odata-sql/azure-documentdb-odata-sql.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<AssemblyName>Microsoft.Azure.Documents.OData.Sql</AssemblyName>
</PropertyGroup>

Expand All @@ -25,4 +25,9 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
11 changes: 9 additions & 2 deletions azure-documentdb-odata-sql/azure-documentdb-odata-sql.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,23 @@
<group targetFramework=".NET6.0">
<dependency id="Microsoft.AspNetCore.OData" version="8.0.7" />
</group>
<group targetFramework=".NET8.0">
<dependency id="Microsoft.AspNetCore.OData" version="9.1.1" />
</group>
</dependencies>
</metadata>

<files>
<file src="bin\Release\netstandard2.0\Microsoft.Azure.Documents.OData.Sql.dll" target="lib\netstandard2.0" />
<file src="bin\Release\netstandard2.0\Microsoft.Azure.Documents.OData.Sql.pdb" target="lib\netstandard2.0" />
<file src="bin\Release\netstandard2.0\Microsoft.Azure.Documents.OData.Sql.XML" target="lib\netstandard2.0" />
<file src="bin\Release\netstandard2.0\Microsoft.Azure.Documents.OData.Sql.pdb" target="lib\netstandard2.0" />
<file src="bin\Release\netstandard2.0\Microsoft.Azure.Documents.OData.Sql.XML" target="lib\netstandard2.0" />
<file src="bin\Release\net6.0\Microsoft.Azure.Documents.OData.Sql.dll" target="lib\net6.0" />
<file src="bin\Release\net6.0\Microsoft.Azure.Documents.OData.Sql.pdb" target="lib\net6.0" />
<file src="bin\Release\net6.0\Microsoft.Azure.Documents.OData.Sql.XML" target="lib\net6.0" />
<file src="bin\Release\net8.0\Microsoft.Azure.Documents.OData.Sql.dll" target="lib\net8.0" />
<file src="bin\Release\net8.0\Microsoft.Azure.Documents.OData.Sql.pdb" target="lib\net8.0" />
<file src="bin\Release\net8.0\Microsoft.Azure.Documents.OData.Sql.XML" target="lib\net8.0" />

</files>

</package>