-
Notifications
You must be signed in to change notification settings - Fork 19
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
CSharp integration #299
Conversation
docker/Dockerfile-ubuntu-20
Outdated
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 && \ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is not possible to run docker commands inside a dockerfile. Or is it?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
docker/Dockerfile-ubuntu-20
Outdated
RUN cd integration/python/ && pytest | ||
|
||
RUN cd .. && \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
{ | ||
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"); | ||
} |
There was a problem hiding this comment.
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.
{ | ||
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"); | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Also I saw Is it ok to have both of them? And they both failed. |
@kotbegemot do we need C# tests for manylinux? @OrangeSmokingJacket I still see falling |
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). |
@SergeiNA manylinux is only needed to build packages for pypi on the linux |
Now able to:
Create a database and a collection
Insert, update, delete and select documents via ExecuteSQL()