Skip to content

Commit 59d2b64

Browse files
author
Kristoffer Sjöberg
committed
Create NetStandard 2.0 library
Split the library in two parts: One runtime library which targets .NET Standard 2.0 and one test library that targets .NET 6 and consumes the runtime library. This way, Xunit and other test-related libraries are not required to be deployed when referencing Look#. It is recommended to use the lowest/oldest .NET Standard version which under which your library can execute to maximize compatibility. In addition, add support for setting custom headers on a request-by-request basis. This is required because Looker requires the User-Agent header to be present when acquiring an embed session.
1 parent 008b838 commit 59d2b64

24 files changed

+172
-133
lines changed

csharp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vs

csharp/csharp.csproj renamed to csharp/LookerSdk.Tests/LookerSdk.Tests.csproj

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22
<PropertyGroup>
33
<TargetFramework>net6.0</TargetFramework>
44
<IsPackable>false</IsPackable>
5-
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
65
<LangVersion>10</LangVersion>
6+
<OutputType>Library</OutputType>
77
</PropertyGroup>
88
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
9-
<OutputPath>bin\Debug/net6.0/</OutputPath>
9+
<OutputPath>bin\Debug</OutputPath>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
13-
<PackageReference Include="xunit" Version="2.4.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
13+
<PackageReference Include="xunit" Version="2.6.1" />
14+
<PackageReference Include="xunit.extensibility.execution" Version="2.6.1" />
1515
<PackageReference Include="coverlet.collector" Version="1.2.0" />
1616
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
17+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
18+
<PrivateAssets>all</PrivateAssets>
19+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
20+
</PackageReference>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ProjectReference Include="..\LookerSdk\LookerSdk.csproj" />
1724
</ItemGroup>
1825
</Project>

csharp/rtl.Tests/ApiMethodsTests.cs renamed to csharp/LookerSdk.Tests/rtl.Tests/ApiMethodsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ public async Task GetHtmlUrlTest()
4444
Assert.Contains(_config.HtmlTestContent, actual);
4545
}
4646
}
47-
}
47+
}

csharp/rtl.Tests/TransportTests.cs renamed to csharp/LookerSdk.Tests/rtl.Tests/TransportTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
22
using System.Net;
33
using System.Net.Http;
4-
using System.Text.Json;
54
using System.Threading.Tasks;
65
using Looker.RTL;
7-
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
6+
using Newtonsoft.Json;
87
using Xunit;
98
using Xunit.Abstractions;
109

@@ -62,7 +61,7 @@ public async Task GetJsonUrlTest()
6261
var content = actual.Body.ToString();
6362
Assert.NotNull(content);
6463
Assert.Contains("looker_release_version", content);
65-
var json = JsonSerializer.Deserialize<Values>(content);
64+
var json = JsonConvert.DeserializeObject<Values>(content);
6665
Assert.Equal(json.Keys, _versionKeys);
6766
}
6867

0 commit comments

Comments
 (0)