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

CSharp integration #299

Merged
merged 19 commits into from
Jan 13, 2024
Merged

CSharp integration #299

merged 19 commits into from
Jan 13, 2024

Conversation

OrangeSmokingJacket
Copy link
Collaborator

@OrangeSmokingJacket OrangeSmokingJacket commented Dec 30, 2023

  1. Name change leftovers
  2. Start of a C# integration, which will be expanded later.
    Now able to:
    Create a database and a collection
    Insert, update, delete and select documents via ExecuteSQL()
  3. Dockerfiles are now 2 stage builds, which lowers final image size and simplifies dotnet usage

python3-dev curl gnupg apt-transport-https \
zlib1g \
wget && \
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be we can wrap all cs dependeces intro one script

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://hub.docker.com/_/microsoft-dotnet-sdk

But it is not possible to run docker commands inside a dockerfile. Or is it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just use it for FROM directive at the top and start with the container, full of M$ libs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case it should be a separate dockerfile isn't it?
cc @CLTanuki @OrangeSmokingJacket

RUN cd integration/python/ && pytest

RUN cd .. && \
Copy link
Collaborator

Choose a reason for hiding this comment

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

@OrangeSmokingJacket @kotbegemot IMHAO I'd like to see separate docker file for dotnet. Or it should be in each docker file.
@kotbegemot I think we need to rethink our approach to docker files infrastructure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So what thoughts on it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So what thoughts on it?

@@ -21,16 +21,16 @@ namespace components::cursor {

enum class operation_status_t { success = 1, failure = 0 };

enum class error_code_t {
enum class error_code_t : int32_t {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need 32 bits here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is for C# conversion, but i think it will work with less bytes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For some weird reason, 32 bits are not necessary for C++, but other types behaves strange in C#...
is_error() function has this code: { return error_.type != error_code_t::none; }, and it works fine with all singed and unsigned types, but C#, which just calls that function returns true even if error_.type is "none" for every type, exept int32_t. And i couldn't figure out why...

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's require by c# fine but plz leave a comment like "We have to use int32_t because of c# comparability type restrictions"

Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -4,6 +4,12 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not think, it is necessary, because project successfully builds without it.

CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr
OtterbrixCreate(TransferConfig config, StringPasser database, StringPasser collection);
[DllImport(libotterbrix,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be empty lines between functions. Take on of public editorconfigs like this and add <TreatWarningsAsErrors>true</TreatWarningsAsErrors> to csproj to avoid having to remember these rules.

CursorWrapper cursor = otterbrix.Execute(query);
Assert.IsTrue(cursor != null);
Assert.IsTrue(cursor.IsSuccess());
Assert.IsFalse(cursor.IsError());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it cannot error if previous assertion passes - it's not a Shroedinger `s cat. Same for other assertions. It can save some CI time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The way i build it, it can, there is a case, when IsSuccess() will be false, but IsError() will also be false.
If we select something but nothing was selected, operation won't be successful, because nothing was selected, but also there won't be any errors, because everything worked fine.
It done that way to simplify some checks when there is need to see if something was selected or not

Comment on lines 92 to 121
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 99);
Assert.IsTrue(doc.GetString("name") == "Name 99");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 98);
Assert.IsTrue(doc.GetString("name") == "Name 98");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 97);
Assert.IsTrue(doc.GetString("name") == "Name 97");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 96);
Assert.IsTrue(doc.GetString("name") == "Name 96");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 95);
Assert.IsTrue(doc.GetString("name") == "Name 95");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about a for loop? Possibly You can end with TestCase parameters - it's easier to read and maintain.

Comment on lines 53 to 82
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 0);
Assert.IsTrue(doc.GetString("name") == "Name 0");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 1);
Assert.IsTrue(doc.GetString("name") == "Name 1");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 2);
Assert.IsTrue(doc.GetString("name") == "Name 2");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 3);
Assert.IsTrue(doc.GetString("name") == "Name 3");
}
{
DocumentWrapper doc = cursor.Next();
Assert.IsTrue(doc != null);
Assert.IsTrue(doc.GetLong("count") == 4);
Assert.IsTrue(doc.GetString("name") == "Name 4");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same about loop.

@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:20.04 as builder
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like you use here Multi-stage builds, plz add info about in into PR description.
Also @kotbegemot PTAL, as more I see cases like this more I want to use separate dockerfile for C# buuut... We need to discuss it.

Copy link
Collaborator

@SergeiNA SergeiNA left a comment

Choose a reason for hiding this comment

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

From my side we need to discus only dockerfile structure. No more significant notes. So fix all c# issue and merge it.

@SergeiNA
Copy link
Collaborator

SergeiNA commented Jan 7, 2024

Also I saw
dotnet package / Run (3.1.x, ubuntu-20.04, 3.8) (pull_request)
dotnet package / Run (6.0.x, ubuntu-20.04, 3.8) (pull_request)

Is it ok to have both of them? And they both failed.
cc @CLTanuki @OrangeSmokingJacket @kotbegemot

@SergeiNA
Copy link
Collaborator

@kotbegemot do we need C# tests for manylinux?

@OrangeSmokingJacket I still see falling
dotnet package / Run (3.1.x, ubuntu-20.04, 3.8) (pull_request)
and why you turn off
dotnet package / Run (6.0.x, ubuntu-20.04, 3.8) (pull_request) ?
Plz add comment.

@OrangeSmokingJacket
Copy link
Collaborator Author

@kotbegemot do we need C# tests for manylinux?

@OrangeSmokingJacket I still see falling dotnet package / Run (3.1.x, ubuntu-20.04, 3.8) (pull_request) and why you turn off dotnet package / Run (6.0.x, ubuntu-20.04, 3.8) (pull_request) ? Plz add comment.

There are 2 test cases in each (the first one is from WrapperTest.cs, which works fine, the second is for EntityFramework, which is not implemented yet).
As far as I know, 3.1.x and 6.0.x are running at the same time and failed one cancels the other one

@kotbegemot
Copy link
Member

kotbegemot commented Jan 12, 2024

@SergeiNA manylinux is only needed to build packages for pypi on the linux

@kotbegemot kotbegemot merged commit 3fab84d into duckstax:develop Jan 13, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants