Skip to content

Commit 5df6220

Browse files
Sl 6372 update for maui support (#42)
1 parent c33ab01 commit 5df6220

8 files changed

Lines changed: 124 additions & 45 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
name: Deploy
22

33
on:
4-
workflow_dispatch:
4+
release:
5+
types: [published]
56

67
jobs:
78
deploy:
89
runs-on: ubuntu-latest
910

1011
steps:
11-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1213
with:
1314
fetch-depth: 0
1415
- name: Setup .NET
15-
uses: actions/setup-dotnet@v1
16+
uses: actions/setup-dotnet@v3
1617
with:
17-
dotnet-version: 6.0.x
18+
dotnet-version: |
19+
3.1.x
20+
6.0.x
21+
7.0.x
22+
- name: Retore Workload
23+
run: dotnet workload restore
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
- name: Set Assembly Version
27+
run: ./build.sh --task=GitVersion --configuration=Release
28+
- name: Build Library
29+
run: dotnet build ./Float.TinCan.ActivityLibrary/Float.TinCan.ActivityLibrary.csproj --configuration Release --no-restore
30+
- name: Update Version
31+
run: sed -i "s/<Version><\/Version>/<Version>${{ github.event.release.name }}<\/Version>/" ./Float.TinCan.ActivityLibrary/Float.TinCan.ActivityLibrary.csproj
32+
- name: Pack and Upload
33+
run: dotnet pack --configuration Release --no-restore
1834

1935
- name: Deploy to NuGet
2036
env:
2137
FLOAT_NUGET_TOKEN: ${{ secrets.FLOAT_NUGET_TOKEN }}
22-
run: ./build.sh --task=Deploy --configuration=Release --nugetUrl="https://api.nuget.org/v3/index.json" --nugetToken="${FLOAT_NUGET_TOKEN}"
38+
run: dotnet nuget push ./Float.TinCan.ActivityLibrary/bin/Release/Float.TinCan.ActivityLibrary.${{ github.event.release.name }}.nupkg --api-key "${FLOAT_NUGET_TOKEN}" --source https://api.nuget.org/v3/index.json

.github/workflows/test.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@ on:
66

77
jobs:
88
build:
9-
109
runs-on: ubuntu-latest
1110

1211
steps:
13-
- uses: actions/checkout@v2
14-
- name: Setup .NET
15-
uses: actions/setup-dotnet@v1
16-
with:
17-
dotnet-version: 6.0.x
18-
- name: Restore dependencies
19-
run: dotnet restore
20-
- name: Build
21-
run: dotnet build --no-restore
22-
- name: Test
23-
run: dotnet test --no-build --verbosity normal
12+
- uses: actions/checkout@v3
13+
- name: Setup .NET
14+
uses: actions/setup-dotnet@v3
15+
with:
16+
dotnet-version: |
17+
3.1.x
18+
6.0.x
19+
7.0.x
20+
- name: Retore Workload
21+
run: dotnet workload restore
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
- name: Build
25+
run: dotnet build --configuration Release --no-restore
26+
- name: Test
27+
run: dotnet test --configuration Release --no-build --verbosity normal --logger:"trx;"
28+
- name: Publish Test Results
29+
uses: EnricoMi/publish-unit-test-result-action@v2
30+
if: always()
31+
with:
32+
files: |
33+
**/TestResults/*.trx

Float.TinCan.ActivityLibrary.Tests/Float.TinCan.ActivityLibrary.Tests.csproj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
44
<IsPackable>false</IsPackable>
5+
<LangVersion>9.0</LangVersion>
6+
<UseMaui>true</UseMaui>
57
</PropertyGroup>
68
<ItemGroup>
79
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
8-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
9-
<PackageReference Include="NunitXml.TestLogger" Version="3.0.127" />
10-
<PackageReference Include="xunit" Version="2.4.2" />
11-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
11+
<PackageReference Include="NunitXml.TestLogger" Version="3.1.15" />
12+
<PackageReference Include="xunit" Version="2.5.0" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
1214
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1315
<PrivateAssets>all</PrivateAssets>
1416
</PackageReference>
15-
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
17+
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
1618
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1719
<PrivateAssets>all</PrivateAssets>
1820
</PackageReference>

Float.TinCan.ActivityLibrary/ActivityDownloader.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics.Contracts;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using Float.FileDownloader;
67
using Float.TinCan.ActivityLibrary.Definition;
8+
#if NETSTANDARD
79
using Xamarin.Forms;
10+
#else
11+
using Microsoft.Maui;
12+
using Microsoft.Maui.ApplicationModel;
13+
#endif
814

915
namespace Float.TinCan.ActivityLibrary
1016
{
@@ -60,11 +66,16 @@ public static DownloadStatus Download(IActivity activity, IRemoteFileProvider fi
6066
{
6167
tasks?.Exception?.Handle(exc =>
6268
{
63-
Device.BeginInvokeOnMainThread(() =>
69+
Action mainThreadCode = () =>
6470
{
6571
DeleteDownloadsForActivity(activity, metaDataProvider);
6672
ActiveDownloads.Remove(activity);
67-
});
73+
};
74+
#if NETSTANDARD
75+
Device.BeginInvokeOnMainThread(mainThreadCode);
76+
#else
77+
MainThread.BeginInvokeOnMainThread(mainThreadCode);
78+
#endif
6879

6980
return true;
7081
});

Float.TinCan.ActivityLibrary/ActivityLaunchCoordinator.cs

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
using Newtonsoft.Json;
1212
using Newtonsoft.Json.Linq;
1313
using TinCan;
14+
#if NETSTANDARD
1415
using Xamarin.Forms;
16+
#else
17+
using Microsoft.Maui;
18+
using Microsoft.Maui.ApplicationModel;
19+
using Microsoft.Maui.Controls;
20+
#endif
1521

1622
namespace Float.TinCan.ActivityLibrary
1723
{
@@ -111,7 +117,7 @@ public override void Start()
111117
}
112118
else
113119
{
114-
Device.BeginInvokeOnMainThread(async () =>
120+
Action mainThreadCode = async () =>
115121
{
116122
try
117123
{
@@ -129,7 +135,12 @@ public override void Start()
129135
downloadStatus.DownloadsCompleted += HandleDownloadCompleted;
130136
downloadStatus.DownloadsCancelled += HandleDownloadCancelled;
131137
await ShowDownloadStatus(CreateDownloadStatusPage(downloadStatus));
132-
});
138+
};
139+
#if NETSTANDARD
140+
Device.BeginInvokeOnMainThread(mainThreadCode);
141+
#else
142+
MainThread.BeginInvokeOnMainThread(mainThreadCode);
143+
#endif
133144
}
134145
}
135146

@@ -243,11 +254,16 @@ protected virtual void OnActivityFinished(object sender, EventArgs args)
243254
/// </summary>
244255
protected void ShowCompletionScreen()
245256
{
246-
Device.BeginInvokeOnMainThread(async () =>
257+
Action mainThreadCode = async () =>
247258
{
248259
var completionPage = CreateActivityCompletePage(AvailablePostAssessments != null && AvailablePostAssessments.Any());
249260
await NavigationContext.PresentPageAsync(completionPage);
250-
});
261+
};
262+
#if NETSTANDARD
263+
Device.BeginInvokeOnMainThread(mainThreadCode);
264+
#else
265+
MainThread.BeginInvokeOnMainThread(mainThreadCode);
266+
#endif
251267
}
252268

253269
/// <summary>
@@ -273,10 +289,15 @@ protected virtual void HandleCancelDownloadRequested(object sender, EventArgs ar
273289
/// <param name="args">Arguments related to the event.</param>
274290
protected virtual void HandleActivityFinished(object sender, EventArgs args)
275291
{
276-
Device.BeginInvokeOnMainThread(() =>
292+
Action mainThreadCode = () =>
277293
{
278294
this.Activity.CompletionDate = DateTimeOffset.Now;
279-
});
295+
};
296+
#if NETSTANDARD
297+
Device.BeginInvokeOnMainThread(mainThreadCode);
298+
#else
299+
MainThread.BeginInvokeOnMainThread(mainThreadCode);
300+
#endif
280301

281302
if (args is not StatementEventArgs statementArgs)
282303
{
@@ -319,10 +340,15 @@ protected virtual void HandleActivityProgressed(object sender, EventArgs args)
319340
return;
320341
}
321342

322-
Device.BeginInvokeOnMainThread(() =>
343+
Action mainThreadCode = () =>
323344
{
324345
this.Activity.PercentComplete = (double)percentComplete / 100;
325-
});
346+
};
347+
#if NETSTANDARD
348+
Device.BeginInvokeOnMainThread(mainThreadCode);
349+
#else
350+
MainThread.BeginInvokeOnMainThread(mainThreadCode);
351+
#endif
326352
}
327353

328354
/// <summary>
@@ -414,7 +440,7 @@ protected virtual void HandleDownloadError(object sender, EventArgs args)
414440

415441
void CreateRunnerAndHandleErrors()
416442
{
417-
Device.BeginInvokeOnMainThread(async () =>
443+
Action mainThreadCode = async () =>
418444
{
419445
try
420446
{
@@ -427,7 +453,12 @@ void CreateRunnerAndHandleErrors()
427453
OnActivityLaunchException(e);
428454
Finish(EventArgs.Empty);
429455
}
430-
});
456+
};
457+
#if NETSTANDARD
458+
Device.BeginInvokeOnMainThread(mainThreadCode);
459+
#else
460+
MainThread.BeginInvokeOnMainThread(mainThreadCode);
461+
#endif
431462
}
432463

433464
/// <summary>

Float.TinCan.ActivityLibrary/Definition/IActivityViewer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using Xamarin.Forms;
1+
#if NETSTANDARD
2+
using Xamarin.Forms;
3+
#else
4+
using Microsoft.Maui;
5+
using Microsoft.Maui.Controls;
6+
#endif
27

38
namespace Float.TinCan.ActivityLibrary.Definition
49
{

Float.TinCan.ActivityLibrary/Float.TinCan.ActivityLibrary.csproj

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<TargetFrameworks>netstandard2;net6.0;net7.0</TargetFrameworks>
44
<AssemblyName>Float.TinCan.ActivityLibrary</AssemblyName>
55
<AssemblyAuthor>Float</AssemblyAuthor>
66
<AssemblyDescription>A library for starting xAPI activities.</AssemblyDescription>
@@ -11,6 +11,9 @@
1111
<Title>$(AssemblyName)</Title>
1212
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1313
<LangVersion>9.0</LangVersion>
14+
<ReleaseVersion>1.0.0</ReleaseVersion>
15+
<Version></Version>
16+
<UseMaui>true</UseMaui>
1417
</PropertyGroup>
1518
<ItemGroup>
1619
<AdditionalFiles Include="$(SolutionDir)/stylecop.json" />
@@ -29,17 +32,19 @@
2932
<PackageReadmeFile>readme.md</PackageReadmeFile>
3033
</PropertyGroup>
3134
<ItemGroup>
32-
<PackageReference Include="Float.FileDownloader" Version="[1.0.0.5,2)" />
33-
<PackageReference Include="Float.TinCan" Version="[1.0.3.29,2)" />
34-
<PackageReference Include="Float.TinCan.LocalLRSServer" Version="[1.0.0.24,2)" />
35-
<PackageReference Include="Xamarin.Forms" Version="[5.0.0.1874,6)" />
36-
<PackageReference Include="Float.Core" Version="[1.0.0.50,2)" />
35+
<PackageReference Include="Float.FileDownloader" Version="1.0.0.44" />
36+
<PackageReference Include="Float.TinCan" Version="1.0.3.30" />
37+
<PackageReference Include="Float.TinCan.LocalLRSServer" Version="2.0.0.1" />
38+
<PackageReference Include="Float.Core" Version="2.0.0" />
3739
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
3840
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3941
<PrivateAssets>all</PrivateAssets>
4042
</PackageReference>
4143
</ItemGroup>
44+
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
45+
<PackageReference Include="Xamarin.Forms" Version="[5.0.0.1874,6)" />
46+
</ItemGroup>
4247
<ItemGroup>
43-
<None Include="../readme.md" Pack="true" PackagePath="\"/>
48+
<None Include="../readme.md" Pack="true" PackagePath="\" />
4449
</ItemGroup>
4550
</Project>

build.cake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ Task("GitVersion")
9292
});
9393

9494
Task("Build")
95-
.IsDependentOn("RestorePackages")
9695
.IsDependentOn("GitVersion")
9796
.Does(() =>
9897
{

0 commit comments

Comments
 (0)