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

upgrade to .Net 8.0 #273

Merged
merged 8 commits into from
Oct 22, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore EFCore.Taos.sln
- name: Build
Expand Down
5 changes: 5 additions & 0 deletions EFCore.Taos.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{61AA7587-946B-4B2F-92C9-73D0BA670B97}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
.workflow\BranchPipeline.yml = .workflow\BranchPipeline.yml
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
LICENSE = LICENSE
docs\logo.png = docs\logo.png
.workflow\MasterPipeline.yml = .workflow\MasterPipeline.yml
.workflow\PRPipeline.yml = .workflow\PRPipeline.yml
README.md = README.md
taos.cfg = taos.cfg
docs\taos_ch.png = docs\taos_ch.png
docs\taos_ch_600.png = docs\taos_ch_600.png
EndProjectSection
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ services:
- taos-network

taos:
image: tdengine/tdengine:3.0.5.1
image: tdengine/tdengine:3.2.1.0
restart: always
hostname: taos
volumes:
- "./taos.cfg:/etc/taos/taos.cfg"
ports:
- 6030:6030
- 6035:6035
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected override Expression VisitExtension(Expression extensionExpression)


return exp;
}
}

private Expression VisitTaosMatchExpression(TaosMatchExpression matchExpression)
{
Expand Down
13 changes: 7 additions & 6 deletions src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using IoTSharp.Data.Taos;
using Carbunql.Analysis;

Check failure on line 1 in src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'Carbunql' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 1 in src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'Carbunql' could not be found (are you missing a using directive or an assembly reference?)
using IoTSharp.Data.Taos;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SqModel.Analysis;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -20,17 +20,17 @@
,station_uid,longitude,latitude,mn,dev_code,pol_name,pol_unit,pol_id FROM st_pmcm WHERE point_code = @p1;";
const string SQLDemo3 = "SELECT * FROM bytable WHERE t1 = @t1 AND t2 LIKE @t11 LIMIT @t3;";
// const string SQLDemo4 = "INSERT INTO t_status USING st_status (status_key) TAGS ('s1') (status_time, val) VALUES (@x1, @x2);";
var s1 = SqlParser.Parse(SQLDemo1);
var s1 = SelectQueryParser.Parse(SQLDemo1);
Assert.AreEqual(0, ((int?)s1.Parameters?.Count).GetValueOrDefault());
var s2 = SqlParser.Parse(SQLDemo2);
var s2 = SelectQueryParser.Parse(SQLDemo2);
Assert.AreEqual(5, ((int?)s2.Parameters?.Count).GetValueOrDefault());

Assert.AreEqual("@p1", s2.Parameters?.Keys.ToArray()[0]);

var pn2 = s2.Parameters;
Assert.AreEqual(1, pn2.Count);
Assert.AreEqual("@p1", pn2.Keys.ToArray()[0]);
var s3 = SqlParser.Parse(SQLDemo3);
var s3 = SelectQueryParser.Parse(SQLDemo3);
Assert.AreEqual(7, s3.Parameters?.Count);
Assert.AreEqual("@t1", s3.Parameters?.ToArray()[1].Key);
Assert.AreEqual("@t11", s3.Parameters?.ToArray()[3].Key);
Expand All @@ -57,7 +57,8 @@
//Assert.AreEqual(2, pn4.Length);
//Assert.AreEqual("@x1", pn4[0]);
//Assert.AreEqual("@x2", pn4[1]);
var s5 = SqlParser.Parse("insert into #subtable using stable tags($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$t12,$t13) values (@t1,@t2,@t3,@t4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14)");

var s5 = SelectQueryParser.Parse("insert into #subtable using stable tags($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$t12,$t13) values (@t1,@t2,@t3,@t4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14)");
Assert.AreEqual(14, s5.Parameters?.Count);
Assert.AreEqual("#subtable", s5.Parameters?.ToArray()[0].Key);
Assert.AreEqual(13, s5.Parameters?.Count(k=>k.Key.StartsWith('$')));
Expand Down
18 changes: 9 additions & 9 deletions src/Example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:7.0-bullseye-slim AS base
MAINTAINER Yanhong Ma 2023
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" > /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list && \
apt-get -y -q update && apt-get install -y --no-install-recommends -q apt-utils libgdiplus libc6-dev lsof net-tools wget curl iputils-ping inetutils-tools && \
FROM mcr.microsoft.com/dotnet/runtime:8.0-bookworm-slim AS base
MAINTAINER Yanhong Ma 2024
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free" > /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free" >> /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free" >> /etc/apt/sources.list && \
apt-get -y -q update && apt-get install -y --no-install-recommends -q apt-utils lsof net-tools wget curl iputils-ping inetutils-tools && \
apt-get autoremove -y && apt-get clean && apt-get autoclean && rm /var/cache/apt/* -rf && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN curl -o TDengine-client.tar.gz "https://www.taosdata.com/assets-download/3.0/TDengine-client-3.0.5.1-Linux-x64.tar.gz" && \
RUN curl -o TDengine-client.tar.gz "https://www.taosdata.com/assets-download/3.0/TDengine-client-3.2.1.0-Linux-x64.tar.gz" && \
tar -xvf TDengine-client.tar.gz && rm TDengine-client.tar.gz -f && cd $(ls TDengine-client* -d) && \
./install_client.sh && \
rm $(pwd) -rf
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build
WORKDIR /src

COPY ["src/Example/Example.csproj", "src/Example/"]
Expand Down
4 changes: 2 additions & 2 deletions src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
IoTSharp.Data.Taos.TaosParameter
IoTSharp.Data.Taos.TaosTransaction
</Description>
<TargetFrameworks>net6;net7;net4.6;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6;net7;net8;net4.6;netstandard2.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<PackageTags>Taos;Data;ADO.NET;Entity Framework,;EF; Core;Data O/RM,;entity-framework-core;TDengine;IoTSharp</PackageTags>
<Authors>Yanhong Ma</Authors>
Expand Down Expand Up @@ -56,7 +56,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net4.6'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
Expand Down
60 changes: 31 additions & 29 deletions src/IoTSharp.Data.Taos/Protocols/TDNative/TaosNative.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using IoTSharp.Data.Taos;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
Expand All @@ -14,7 +15,7 @@ namespace IoTSharp.Data.Taos.Protocols
{
internal class TaosNative : ITaosProtocol
{
private static readonly Dictionary<string, ConcurrentTaosQueue> g_pool = new Dictionary<string, ConcurrentTaosQueue>();
private static readonly ConcurrentDictionary<string, ConcurrentTaosQueue> g_pool = new ConcurrentDictionary<string, ConcurrentTaosQueue>();
private ConcurrentTaosQueue _queue = null;
private static bool _dll_isloaded = false;
private readonly DateTime _dt1970;
Expand Down Expand Up @@ -117,52 +118,53 @@ public string GetClientVersion()
public bool Open(TaosConnectionStringBuilder builder)
{
var _connectionString = builder.ConnectionString;
if (!g_pool.ContainsKey(_connectionString))
lock (g_pool)
{
g_pool.Add(_connectionString, new ConcurrentTaosQueue() { Timeout = builder.ConnectionTimeout });
}
_queue = g_pool[_connectionString];
_queue.AddRef();

for (int i = 0; i < builder.PoolSize + 1; i++)
{
var c = TDengine.Connect(builder.DataSource, builder.Username, builder.Password, "", (short)builder.Port);
if (c != IntPtr.Zero)
_queue = g_pool.GetOrAdd(_connectionString, new ConcurrentTaosQueue() { Timeout = builder.ConnectionTimeout });
_queue.AddRef();
for (int i = 0; i < builder.PoolSize + 1; i++)
{
_queue.Return(c);
var c = TDengine.Connect(builder.DataSource, builder.Username, builder.Password, "", (short)builder.Port);
if (c != IntPtr.Zero)
{
_queue.Return(c);
}
}
if (_queue.TaosQueue.IsEmpty)
{
TaosException.ThrowExceptionForRC(new TaosErrorResult() { Code = -1, Error = "Can't open connection." });
}
}
if (_queue.TaosQueue.IsEmpty)
{
TaosException.ThrowExceptionForRC(new TaosErrorResult() { Code = -1, Error = "Can't open connection." });
}
return true;
}

public void Close(TaosConnectionStringBuilder builder)
{
var _connectionString = builder.ConnectionString;
_queue.RemoveRef();
if (_queue.GetRef() == 0)
lock (g_pool)
{
for (int i = 0; i < _queue.TaosQueue.Count; i++)
_queue.RemoveRef();
if (_queue.GetRef() == 0)
{
try
for (int i = 0; i < _queue.TaosQueue.Count; i++)
{
var tk = _queue.Take();
if (tk != IntPtr.Zero)
try
{
TDengine.Close(tk);
var tk = _queue.Take();
if (tk != IntPtr.Zero)
{
TDengine.Close(tk);
}
}
}
catch (Exception)
{
catch (Exception)
{



}
}
_queue = null;
g_pool.TryRemove(_connectionString, out var va1l);
}
_queue = null;
g_pool.Remove(_connectionString);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
private ClientWebSocket _ws_client = null;
private ClientWebSocket _stmt_client = null;
private ClientWebSocket _schemaless_client = null;
private string _databaseName;

Check warning on line 23 in src/IoTSharp.Data.Taos/Protocols/TDWebSocket/TaosWebSocket.cs

View workflow job for this annotation

GitHub Actions / build

The field 'TaosWebSocket._databaseName' is never used

Check warning on line 23 in src/IoTSharp.Data.Taos/Protocols/TDWebSocket/TaosWebSocket.cs

View workflow job for this annotation

GitHub Actions / build

The field 'TaosWebSocket._databaseName' is never used

Check warning on line 23 in src/IoTSharp.Data.Taos/Protocols/TDWebSocket/TaosWebSocket.cs

View workflow job for this annotation

GitHub Actions / build

The field 'TaosWebSocket._databaseName' is never used

Check warning on line 23 in src/IoTSharp.Data.Taos/Protocols/TDWebSocket/TaosWebSocket.cs

View workflow job for this annotation

GitHub Actions / build

The field 'TaosWebSocket._databaseName' is never used

Check warning on line 23 in src/IoTSharp.Data.Taos/Protocols/TDWebSocket/TaosWebSocket.cs

View workflow job for this annotation

GitHub Actions / build

The field 'TaosWebSocket._databaseName' is never used
private TaosConnectionStringBuilder _builder;

public bool ChangeDatabase(string databaseName)
Expand Down Expand Up @@ -447,7 +447,7 @@

private bool _ws_conn(TaosConnectionStringBuilder builder, ClientWebSocket _client)
{
var rep = WSExecute<WSConnRsp, WSConnReq>(_client, new WSActionReq<WSConnReq>() { Action = "conn", Args = new WSConnReq() { user = builder.Username, password = builder.Password, req_id = 0, db = builder.DataBase } });
var rep = WSExecute<WSConnRsp, WSConnReq>(_client, new WSActionReq<WSConnReq>() { Action = "conn", Args = new WSConnReq() { user = builder.Username, password = builder.Password, req_id = 0 } });
if (rep.code == 899)
{
rep = WSExecute<WSConnRsp, WSConnReq>(_client, new WSActionReq<WSConnReq>() { Action = "conn", Args = new WSConnReq() { user = builder.Username, password = builder.Password, req_id = 0 } });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
<TargetFramework>net8</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.1</Version>
<PackageLicenseExpression></PackageLicenseExpression>
Expand All @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.3" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="6.0.3" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ORMExample/ORMExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Loading