Skip to content

Commit

Permalink
Move protobuf project to SDK (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
einarmo authored Nov 1, 2023
1 parent 2b165de commit 86dde3f
Show file tree
Hide file tree
Showing 17 changed files with 3,181 additions and 64 deletions.
18 changes: 18 additions & 0 deletions CogniteSdk.Protobuf/CogniteSdk.Protobuf.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Protocol buffers for CogniteSdk</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>CogniteSdk.Protobuf</PackageId>
<Author>Cognite AS</Author>
<Company>Cognite AS</Company>
<Copyright>Cognite AS</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<AssemblyOriginatorKeyFile>$(SolutionDir)/strong_name.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath=""/>
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
623 changes: 623 additions & 0 deletions CogniteSdk.Protobuf/DataPointInsertionRequest.cs

Large diffs are not rendered by default.

831 changes: 831 additions & 0 deletions CogniteSdk.Protobuf/DataPointListResponse.cs

Large diffs are not rendered by default.

1,607 changes: 1,607 additions & 0 deletions CogniteSdk.Protobuf/DataPoints.cs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions CogniteSdk.Protobuf/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group Protobuf

Google.Protobuf
28 changes: 14 additions & 14 deletions CogniteSdk.Types/Units/UnitItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class ConversionFactor
/// The multiplier to convert from the unit to the base unit.
/// </summary>
public double Multiplier { get; set; }

/// <summary>
/// The offset to convert from the unit to the base unit.
/// </summary>
public double Offset { get; set; }

/// <inheritdoc />
public override string ToString() => Stringable.ToString(this);
}

/// <summary>
/// UnitItem read class.
/// </summary>
Expand All @@ -34,49 +34,49 @@ public class UnitItem
/// Unique identifier of the unit.
/// </summary>
public string ExternalId { get; set; }

/// <summary>
/// Name of the unit, e.g. `DEG_C` for Celsius.
/// </summary>
public string Name { get; set; }

/// <summary>
/// More descriptive name of the unit, e.g., `degrees Celsius`.
/// </summary>
public string LongName { get; set; }

/// <summary>
/// The symbol of the unit, e.g., `°C`.
/// </summary>
public string Symbol { get; set; }

/// <summary>
/// List of alias names for the unit, e.g., `Degree C`, `degC`, `°C`, and so on.
/// </summary>
public IEnumerable<string> AliasNames { get; set; }

/// <summary>
/// The quantity of the unit, e.g., `Temperature`.
/// </summary>
public string Quantity { get; set; }

/// <summary>
/// The conversion between the unit and its base unit. For example, the base unit
/// for Temperature is Kelvin, and the conversion from Celsius to Kelvin is
/// multiplier = 1, offset = 273.15.
/// </summary>
public ConversionFactor Conversion { get; set; }

/// <summary>
/// The source of the unit, e.g., `qudt.org`.
/// </summary>
public string? Source { get; set; }
public string Source { get; set; }

/// <summary>
/// The reference to the source of the unit, e.g., `http://qudt.org/vocab/unit/DEG_C`.
/// </summary>
public string? SourceReference { get; set; }
public string SourceReference { get; set; }

/// <inheritdoc />
public override string ToString() => Stringable.ToString(this);
}
Expand Down
2 changes: 1 addition & 1 deletion CogniteSdk/test/csharp/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ await WriteClient.Annotations.CreateAsync(new List<AnnotationCreate> { createAnn
}
};
var updatedAnnotation = (await WriteClient.Annotations.UpdateAsync(updateAnnotationQuery)
.ConfigureAwait(false)).FirstOrDefault();
).FirstOrDefault();
Assert.True(updatedAnnotation.Id == annotation.Id, "The updated annotation id doesn't match with the created one.");
Assert.True(updatedAnnotation.Status == "rejected", "The status of the annotation is not updated.");
Assert.True(updatedAnnotation.Data.Region.First().Cylinder is null, "The data of the annotation is not updated.");
Expand Down
2 changes: 1 addition & 1 deletion CogniteSdk/test/csharp/Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public async Task UpdatedAssetsLabelPerformsExpectedChangesAsync()
};

// Act
_ = await WriteClient.Assets.CreateAsync(new List<AssetCreate>() { initialAsset }).ConfigureAwait(false);
_ = await WriteClient.Assets.CreateAsync(new List<AssetCreate>() { initialAsset });
await WriteClient.Assets.UpdateAsync(update);

var getRes = await WriteClient.Assets.RetrieveAsync(new List<string>() { externalIdString });
Expand Down
3 changes: 2 additions & 1 deletion CogniteSdk/test/fsharp/Files.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Tests.Integration.Files

open System
open System.Collections.Generic
open System.Threading.Tasks

open Xunit
open Swensen.Unquote
Expand Down Expand Up @@ -49,7 +50,7 @@ let ``Get file by missing id is Error`` () = task {
let fileId = 0L

// Act
Assert.ThrowsAsync<ResponseException>(fun () -> readClient.Files.GetAsync fileId :> _)
Assert.ThrowsAsync<ResponseException>(Func<Task>(fun () -> readClient.Files.GetAsync fileId :> _))
|> ignore
}
[<Trait("resource", "files")>]
Expand Down
5 changes: 3 additions & 2 deletions CogniteSdk/test/fsharp/TimeSeries.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Tests.Integration.Timeseries

open System
open System.Collections.Generic
open System.Threading.Tasks

open FSharp.Control.TaskBuilder
open Swensen.Unquote
Expand Down Expand Up @@ -55,7 +56,7 @@ let ``Get timeseries by missing id is Error`` () = task {
let id = 0L

// Act
Assert.ThrowsAsync<ArgumentException>(fun () -> readClient.TimeSeries.GetAsync id :> _)
Assert.ThrowsAsync<ArgumentException>(Func<Task>(fun () -> readClient.TimeSeries.GetAsync id :> _))
|> ignore
}

Expand Down Expand Up @@ -86,7 +87,7 @@ let ``Get timeseries by missing ids is Error`` () = task {
let id = Identity 0L

// Act
Assert.ThrowsAsync<ArgumentException>(fun () -> readClient.TimeSeries.RetrieveAsync [ id ] :> _)
Assert.ThrowsAsync<ArgumentException>(Func<Task>(fun () -> readClient.TimeSeries.RetrieveAsync [ id ] :> _))
|> ignore
}

Expand Down
1 change: 1 addition & 0 deletions Oryx.Cognite/src/Oryx.Cognite.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../CogniteSdk.Types/CogniteSdk.Types.csproj" />
<ProjectReference Include="../../CogniteSdk.Protobuf/CogniteSdk.Protobuf.csproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
1 change: 0 additions & 1 deletion Oryx.Cognite/src/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ group Oryx.Cognite
Oryx
Oryx.SystemTextJson
Oryx.Protobuf
CogniteSdk.Protobuf
14 changes: 14 additions & 0 deletions cognite-sdk-dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CogniteSdk.FSharp", "Cognit
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CogniteSdk.Test.CSharp", "CogniteSdk\test\csharp\CogniteSdk.Test.csproj", "{B42088FD-0284-46D8-8C34-EE348DC02850}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CogniteSdk.Protobuf", "CogniteSdk.Protobuf\CogniteSdk.Protobuf.csproj", "{70C1CDD1-42CB-4823-83B2-F08A4E930096}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -115,6 +117,18 @@ Global
{B42088FD-0284-46D8-8C34-EE348DC02850}.Release|x64.Build.0 = Release|Any CPU
{B42088FD-0284-46D8-8C34-EE348DC02850}.Release|x86.ActiveCfg = Release|Any CPU
{B42088FD-0284-46D8-8C34-EE348DC02850}.Release|x86.Build.0 = Release|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Debug|x64.ActiveCfg = Debug|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Debug|x64.Build.0 = Debug|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Debug|x86.ActiveCfg = Debug|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Debug|x86.Build.0 = Debug|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Release|Any CPU.Build.0 = Release|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Release|x64.ActiveCfg = Release|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Release|x64.Build.0 = Release|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Release|x86.ActiveCfg = Release|Any CPU
{70C1CDD1-42CB-4823-83B2-F08A4E930096}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 6 additions & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ group Oryx.Cognite

nuget FSharp.Core >= 7 lowest_matching: true
nuget System.Text.Json >= 6 lowest_matching: true
nuget CogniteSdk.Protobuf
nuget Oryx ~> 5
nuget Oryx.Protobuf ~> 5
nuget Oryx.SystemTextJson ~> 5
Expand All @@ -31,6 +30,12 @@ group CogniteSdk.FSharp
nuget Oryx ~> 5
nuget FsToolkit.ErrorHandling ~> 4

group Protobuf
source https://www.nuget.org/api/v2
framework: netstandard2.0

nuget Google.Protobuf ~> 3

group Types
source https://www.nuget.org/api/v2
framework: netstandard2.0
Expand Down
Loading

0 comments on commit 86dde3f

Please sign in to comment.