From b7db4cb8d6daed8a9849f1a7d8bdf6acb6117e19 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 6 Dec 2023 21:50:28 +0100 Subject: [PATCH] Fix CI builds (#3484) * Fix CI builds * More fix attempts * Try using a newer .net version * Change the SDK version again * .. * Upgrade analyzers, fix build warnings * Fix the locale of a few tests * Unignore some tests * Expect loggedout * adjust expectation --- .github/templates/build-packages.yml | 2 +- .github/templates/codeql.yml | 2 +- .github/templates/common.lib.yml | 15 ++++- .github/templates/test-android.yml | 6 +- .github/templates/test-ios.yml | 2 +- .github/templates/test-macos.yml | 2 +- .github/templates/test-source-generation.yml | 2 +- .github/templates/test-uwp-managed.yml | 2 +- .github/templates/test-weaver.yml | 2 +- .github/workflows/build-packages.yml | 13 +++- .github/workflows/codeql.yml | 9 +++ .github/workflows/test-android.yml | 14 ++++ .github/workflows/test-ios.yml | 4 ++ .github/workflows/test-macos.yml | 4 ++ .github/workflows/test-source-generation.yml | 4 ++ .github/workflows/test-uwp-managed.yml | 2 +- .github/workflows/test-weaver.yml | 4 ++ Realm.sln.DotSettings | 2 + Realm/Realm.Fody/ModuleWeaver.cs | 16 ++--- Realm/Realm.Fody/Realm.Fody.csproj | 7 +- .../Realm.PlatformHelpers.csproj | 4 +- .../Realm.SourceGenerator.csproj | 2 +- .../Realm.UnityWeaver.csproj | 2 +- Realm/Realm.UnityWeaver/UnityWeaver.cs | 67 +++++++++---------- Realm/Realm.Weaver/Analytics/Analytics.cs | 32 +++++++-- Realm/Realm/Realm.csproj | 2 +- Tests/Benchmarks/Benchmarks/Benchmarks.csproj | 2 +- Tests/Realm.Tests/Database/CollectionTests.cs | 4 +- Tests/Realm.Tests/Realm.Tests.csproj | 2 +- Tests/Realm.Tests/Sync/FunctionsTests.cs | 5 +- Tests/Realm.Tests/Sync/SessionTests.cs | 3 - Tests/Realm.Tests/Sync/UserManagementTests.cs | 10 ++- Tools/DeployApps/DeployApps.csproj | 2 +- global.json | 6 ++ 34 files changed, 170 insertions(+), 87 deletions(-) create mode 100644 global.json diff --git a/.github/templates/build-packages.yml b/.github/templates/build-packages.yml index cbba0a705f..ff3f6638b8 100644 --- a/.github/templates/build-packages.yml +++ b/.github/templates/build-packages.yml @@ -87,7 +87,7 @@ jobs: steps: - #@ template.replace(checkoutCode()) - #@ template.replace(setupAndroid()) - - #@ setupWorkloads('tvos ios maccatalyst android') + - #@ template.replace(setupWorkloads('tvos ios maccatalyst android')) - name: Set version suffix id: set-version-suffix #! Build suffix is pr-1234.5 for pr builds or alpha.123 for branch builds. diff --git a/.github/templates/codeql.yml b/.github/templates/codeql.yml index 0c5d12d7b9..66a77aaf86 100644 --- a/.github/templates/codeql.yml +++ b/.github/templates/codeql.yml @@ -21,7 +21,7 @@ #@ def buildPackages(): - #@ template.replace(setupAndroid()) - - #@ setupWorkloads('tvos ios maccatalyst android') + - #@ template.replace(setupWorkloads('tvos ios maccatalyst android')) - name: Add msbuild to PATH uses: #@ actionSetupMSBuild #@ for pkgName in nugetPackages: diff --git a/.github/templates/common.lib.yml b/.github/templates/common.lib.yml index fe59fa01ac..b2b14e3845 100644 --- a/.github/templates/common.lib.yml +++ b/.github/templates/common.lib.yml @@ -17,6 +17,7 @@ #@ actionReleaseToSlack = "realm/ci-actions/release-to-slack@fa20eb972b9f018654fdb4e2c7afb52b0532f907" #@ actionSetupXcode = "maxim-lobanov/setup-xcode@9a697e2b393340c3cacd97468baa318e4c883d98" #@ actionSetupAndroid = "android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc" +#@ actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0" #@ androidABIs = [ 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' ] #@ windowsArchs = [ 'Win32', 'x64', 'ARM64' ] @@ -230,8 +231,9 @@ with: #@ end --- #@ def setupWorkloads(workloads = 'maui'): -name: Setup workloads -run: #@ "dotnet workload install " + workloads + - _: #@ template.replace(setupDotnet("7.0.x")) + - name: Setup workloads + run: #@ "dotnet workload install " + workloads #@ end --- #@ def restoreWorkloads(workingDirectory = 'Realm/Realm.PlatformHelpers'): @@ -245,4 +247,13 @@ working-directory: #@ "${{ github.workspace }}/" + workingDirectory uses: #@ actionSetupAndroid - name: Install SDK platform 21 run: sdkmanager --install "platforms;android-21" + - #@ setupJDK() #@ end +--- +#@ def setupJDK(): +name: Setup JDK +uses: #@ actionSetupJDK +with: + distribution: microsoft + java-version: 11 +#@ end \ No newline at end of file diff --git a/.github/templates/test-android.yml b/.github/templates/test-android.yml index 4d6e619170..1671ca899f 100644 --- a/.github/templates/test-android.yml +++ b/.github/templates/test-android.yml @@ -1,5 +1,5 @@ #@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "configureAWSCredentials", "fetchPackageArtifacts", "setupWorkloads") +#@ load("common.lib.yml", "checkoutCode", "configureAWSCredentials", "fetchPackageArtifacts", "setupWorkloads", "setupJDK") #@ load("test.lib.yml", "baasTestArgs", "publishTestsResults", "testDefinition", "buildTests", "prepareTest") --- @@ -11,6 +11,7 @@ jobs: name: Xamarin.Android timeout-minutes: 60 steps: + - #@ setupJDK() - #@ template.replace(prepareTest("android")) - #@ template.replace(buildTests("Tests/Tests.Android", target="SignAndroidPackage", AndroidUseSharedRuntime="False", EmbedAssembliesIntoApk="True")) - #@ template.replace(configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2")) @@ -32,7 +33,8 @@ jobs: steps: - #@ template.replace(checkoutCode()) - #@ template.replace(fetchPackageArtifacts()) - - #@ setupWorkloads() + - #@ template.replace(setupWorkloads()) + - #@ setupJDK() - name: Build the tests run: #@ "dotnet publish Tests/Tests.Maui -c Release -f net6.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - #@ template.replace(configureAWSCredentials("AWS_DEVICEFARM_ACCESS_KEY_ID", "AWS_DEVICEFARM_SECRET_ACCESS_KEY", "us-west-2")) diff --git a/.github/templates/test-ios.yml b/.github/templates/test-ios.yml index 06893d0466..4397ce2eed 100644 --- a/.github/templates/test-ios.yml +++ b/.github/templates/test-ios.yml @@ -34,7 +34,7 @@ jobs: run: | sudo xcode-select -s "/Applications/Xcode_14.3.app" echo "MD_APPLE_SDK_ROOT=/Applications/Xcode_14.3.app" >> $GITHUB_ENV - - #@ setupWorkloads() + - #@ template.replace(setupWorkloads()) - name: Build the tests run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net6.0-ios -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - name: Run the tests diff --git a/.github/templates/test-macos.yml b/.github/templates/test-macos.yml index a1a654ef50..079ec0999a 100644 --- a/.github/templates/test-macos.yml +++ b/.github/templates/test-macos.yml @@ -23,7 +23,7 @@ jobs: steps: - #@ template.replace(checkoutCode()) - #@ template.replace(fetchPackageArtifacts()) - - #@ setupWorkloads() + - #@ template.replace(setupWorkloads()) - name: Build the tests run: #@ "dotnet build Tests/Tests.Maui -c " + configuration + " -f net6.0-maccatalyst -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }}" - name: Run the tests diff --git a/.github/templates/test-source-generation.yml b/.github/templates/test-source-generation.yml index 5938e8536f..39eb311a04 100644 --- a/.github/templates/test-source-generation.yml +++ b/.github/templates/test-source-generation.yml @@ -13,7 +13,7 @@ jobs: timeout-minutes: 45 steps: - #@ template.replace(checkoutCode()) - - #@ setupWorkloads('tvos ios maccatalyst android') + - #@ template.replace(setupWorkloads('tvos ios maccatalyst android')) - #@ template.replace(dotnetPublish("Tests/SourceGenerators/Realm.SourceGenerator.Tests", "net6.0", "win-x64")) - name: Run the tests run: #@ "${{ steps.dotnet-publish.outputs.executable-path }}/Realm.SourceGenerator.Tests --result=TestResults.SourceGeneration.xml" diff --git a/.github/templates/test-uwp-managed.yml b/.github/templates/test-uwp-managed.yml index 40887279aa..ab7d88dfd1 100644 --- a/.github/templates/test-uwp-managed.yml +++ b/.github/templates/test-uwp-managed.yml @@ -7,7 +7,7 @@ name: test-uwp-managed _: #@ template.replace(testDefinition(["Base64_Encoded_Pfx", "Pfx_Password"])) jobs: run-tests: - runs-on: windows-2019 + runs-on: windows-latest name: UWP timeout-minutes: 45 steps: diff --git a/.github/templates/test-weaver.yml b/.github/templates/test-weaver.yml index e523536ab7..0452dd2ab2 100644 --- a/.github/templates/test-weaver.yml +++ b/.github/templates/test-weaver.yml @@ -25,7 +25,7 @@ jobs: timeout-minutes: 30 steps: - #@ template.replace(checkoutCode()) - - #@ setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}") + - #@ template.replace(setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}")) - #@ template.replace(dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}")) - name: Run Tests run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 9c9d425caa..e788a73dc6 100755 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -33,6 +33,15 @@ jobs: uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc - name: Install SDK platform 21 run: sdkmanager --install "platforms;android-21" + - name: Setup JDK + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + distribution: microsoft + java-version: 11 + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install tvos ios maccatalyst android - name: Set version suffix @@ -210,11 +219,11 @@ jobs: uses: nirinchev/cache@29e8e4dd9148ea81f9e188480132072cb6cc92d8 with: path: C:\docfx - key: docfx-2.62.1 + key: docfx-2.70.4 - name: Download docfx if: inputs.build-docs && steps.check-docfx-cache.outputs.cache-hit != 'true' run: | - Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.62.1/docfx-win-x64-v2.62.1.zip -OutFile C:\docfx.zip + Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.70.4/docfx-win-x64-v2.70.4.zip -OutFile C:\docfx.zip Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx shell: powershell - name: Configure .NET diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8ba5266586..a1e5cfe7cd 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -45,6 +45,15 @@ jobs: uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc - name: Install SDK platform 21 run: sdkmanager --install "platforms;android-21" + - name: Setup JDK + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + distribution: microsoft + java-version: 11 + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install tvos ios maccatalyst android - name: Add msbuild to PATH diff --git a/.github/workflows/test-android.yml b/.github/workflows/test-android.yml index 7522fb8381..45275322c4 100755 --- a/.github/workflows/test-android.yml +++ b/.github/workflows/test-android.yml @@ -38,6 +38,11 @@ jobs: name: Xamarin.Android timeout-minutes: 60 steps: + - name: Setup JDK + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + distribution: microsoft + java-version: 11 - name: Checkout code uses: actions/checkout@v3 with: @@ -123,8 +128,17 @@ jobs: with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install maui + - name: Setup JDK + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + distribution: microsoft + java-version: 11 - name: Build the tests run: dotnet publish Tests/Tests.Maui -c Release -f net6.0-android -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ inputs.version }} - name: Configure AWS Credentials diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index cd3b1f0804..88f6377c9b 100755 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -112,6 +112,10 @@ jobs: run: | sudo xcode-select -s "/Applications/Xcode_14.3.app" echo "MD_APPLE_SDK_ROOT=/Applications/Xcode_14.3.app" >> $GITHUB_ENV + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install maui - name: Build the tests diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index f01c7c06eb..f8a5fbb929 100755 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -102,6 +102,10 @@ jobs: with: name: Realm.${{ inputs.version }} path: ${{ github.workspace }}/Realm/packages/ + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install maui - name: Build the tests diff --git a/.github/workflows/test-source-generation.yml b/.github/workflows/test-source-generation.yml index 32db8b2767..11de3d0de5 100644 --- a/.github/workflows/test-source-generation.yml +++ b/.github/workflows/test-source-generation.yml @@ -16,6 +16,10 @@ jobs: run: echo "::add-matcher::.github/problem-matchers/csc.json" - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install tvos ios maccatalyst android - name: Publish Tests/SourceGenerators/Realm.SourceGenerator.Tests diff --git a/.github/workflows/test-uwp-managed.yml b/.github/workflows/test-uwp-managed.yml index 88f515e4db..3f559c6720 100755 --- a/.github/workflows/test-uwp-managed.yml +++ b/.github/workflows/test-uwp-managed.yml @@ -30,7 +30,7 @@ env: DOTNET_NOLOGO: true jobs: run-tests: - runs-on: windows-2019 + runs-on: windows-latest name: UWP timeout-minutes: 45 steps: diff --git a/.github/workflows/test-weaver.yml b/.github/workflows/test-weaver.yml index 54f3e53f0e..73df913678 100755 --- a/.github/workflows/test-weaver.yml +++ b/.github/workflows/test-weaver.yml @@ -28,6 +28,10 @@ jobs: run: echo "::add-matcher::.github/problem-matchers/csc.json" - name: Register msvc problem matcher run: echo "::add-matcher::.github/problem-matchers/msvc.json" + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} - name: Publish Tests/Weaver/Realm.Fody.Tests diff --git a/Realm.sln.DotSettings b/Realm.sln.DotSettings index 063b037a0f..d77ab74886 100644 --- a/Realm.sln.DotSettings +++ b/Realm.sln.DotSettings @@ -1,4 +1,6 @@  + MI + OS True True True diff --git a/Realm/Realm.Fody/ModuleWeaver.cs b/Realm/Realm.Fody/ModuleWeaver.cs index f2cc8995d6..277dafbaa8 100644 --- a/Realm/Realm.Fody/ModuleWeaver.cs +++ b/Realm/Realm.Fody/ModuleWeaver.cs @@ -83,17 +83,17 @@ private Config GetAnalyticsConfig(FrameworkName netFramework) var framework = AnalyticsUtils.GetFrameworkAndVersion(ModuleDefinition); - return new() + return new( + targetOSName: AnalyticsUtils.GetTargetOsName(netFramework), + netFrameworkTarget: netFramework.Identifier, + netFrameworkTargetVersion: netFramework.Version.ToString(), + installationMethod: "Nuget", + frameworkName: framework.Name, + frameworkVersion: framework.Version, + compiler: "msbuild") { AnalyticsCollection = analyticsCollection, AnalyticsLogPath = Config.Attribute("AnalyticsLogPath")?.Value, - InstallationMethod = "Nuget", - NetFrameworkTarget = netFramework.Identifier, - NetFrameworkTargetVersion = netFramework.Version.ToString(), - TargetOSName = AnalyticsUtils.GetTargetOsName(netFramework), - FrameworkName = framework.Name, - FrameworkVersion = framework.Version, - Compiler = "msbuild", }; } diff --git a/Realm/Realm.Fody/Realm.Fody.csproj b/Realm/Realm.Fody/Realm.Fody.csproj index d319d1bdd4..29d4e665b3 100644 --- a/Realm/Realm.Fody/Realm.Fody.csproj +++ b/Realm/Realm.Fody/Realm.Fody.csproj @@ -7,18 +7,19 @@ weaver true Realm.Fody - Realm.Fody is a Fody weaver used to replace the property setters and getters of your Realm models with Realm-backed ones. + Realm.Fody is a Fody weaver used to replace the property setters and getters of + your Realm models with Realm-backed ones. $(ProjectDir)..\..\global.ruleset true $(NoWarn),1591, NU5100, NU5128, CA1050 - 11.0 + 10.0 False $(DefineConstants);PRIVATE_INDEXTYPE enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Realm/Realm.PlatformHelpers/Realm.PlatformHelpers.csproj b/Realm/Realm.PlatformHelpers/Realm.PlatformHelpers.csproj index 9232c21ff6..d976a3ba86 100644 --- a/Realm/Realm.PlatformHelpers/Realm.PlatformHelpers.csproj +++ b/Realm/Realm.PlatformHelpers/Realm.PlatformHelpers.csproj @@ -9,12 +9,12 @@ netstandard2.0 - + $(TargetFrameworks);net6.0-ios;net6.0-android;net6.0-maccatalyst;net6.0-tvos - + $(TargetFrameworks);MonoAndroid5;Xamarin.iOS10;Xamarin.TVOS10;Xamarin.Mac20 $(TargetFrameworks);uap10.0.19041; diff --git a/Realm/Realm.SourceGenerator/Realm.SourceGenerator.csproj b/Realm/Realm.SourceGenerator/Realm.SourceGenerator.csproj index 6ada387c15..cb05ef73fc 100644 --- a/Realm/Realm.SourceGenerator/Realm.SourceGenerator.csproj +++ b/Realm/Realm.SourceGenerator/Realm.SourceGenerator.csproj @@ -23,7 +23,7 @@ Realms.SourceGenerator - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Realm/Realm.UnityWeaver/Realm.UnityWeaver.csproj b/Realm/Realm.UnityWeaver/Realm.UnityWeaver.csproj index 655756eb34..0fd60d8745 100644 --- a/Realm/Realm.UnityWeaver/Realm.UnityWeaver.csproj +++ b/Realm/Realm.UnityWeaver/Realm.UnityWeaver.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Realm/Realm.UnityWeaver/UnityWeaver.cs b/Realm/Realm.UnityWeaver/UnityWeaver.cs index 8dc5c19f96..e59064caa1 100644 --- a/Realm/Realm.UnityWeaver/UnityWeaver.cs +++ b/Realm/Realm.UnityWeaver/UnityWeaver.cs @@ -21,6 +21,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using Mono.Cecil.Cil; using UnityEditor; @@ -31,10 +32,7 @@ using UnityEditor.PackageManager.Requests; using UnityEngine; using static RealmWeaver.Analytics; -using CpuArchitecture = RealmWeaver.Metric.CpuArchitecture; -using OperatingSystem = RealmWeaver.Metric.OperatingSystem; - -using BindingFlags = System.Reflection.BindingFlags; +using Assembly = UnityEditor.Compilation.Assembly; // ReSharper disable once CheckNamespace namespace RealmWeaver @@ -425,9 +423,9 @@ private static string GetTargetOSName(BuildTarget? target) { return Application.platform switch { - RuntimePlatform.WindowsEditor => OperatingSystem.Windows, - RuntimePlatform.OSXEditor => OperatingSystem.MacOS, - RuntimePlatform.LinuxEditor => OperatingSystem.Linux, + RuntimePlatform.WindowsEditor => Metric.OperatingSystem.Windows, + RuntimePlatform.OSXEditor => Metric.OperatingSystem.MacOS, + RuntimePlatform.LinuxEditor => Metric.OperatingSystem.Linux, _ => Metric.Unknown(Application.platform.ToString()), }; } @@ -435,13 +433,13 @@ private static string GetTargetOSName(BuildTarget? target) // These have to match Analytics.GetConfig(FrameworkName) return target switch { - BuildTarget.StandaloneOSX => OperatingSystem.MacOS, - BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64 or BuildTarget.WSAPlayer => OperatingSystem.Windows, - BuildTarget.iOS => OperatingSystem.Ios, - BuildTarget.Android => OperatingSystem.Android, - BuildTarget.StandaloneLinux64 => OperatingSystem.Linux, - BuildTarget.tvOS => OperatingSystem.TvOs, - BuildTarget.XboxOne => OperatingSystem.XboxOne, + BuildTarget.StandaloneOSX => Metric.OperatingSystem.MacOS, + BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64 or BuildTarget.WSAPlayer => Metric.OperatingSystem.Windows, + BuildTarget.iOS => Metric.OperatingSystem.Ios, + BuildTarget.Android => Metric.OperatingSystem.Android, + BuildTarget.StandaloneLinux64 => Metric.OperatingSystem.Linux, + BuildTarget.tvOS => Metric.OperatingSystem.TvOs, + BuildTarget.XboxOne => Metric.OperatingSystem.XboxOne, _ => Metric.Unknown(target.ToString()), }; } @@ -513,16 +511,15 @@ private static Config GetAnalyticsConfig(BuildTarget? target = null) Environment.GetEnvironmentVariable("REALM_DISABLE_ANALYTICS") == null && Environment.GetEnvironmentVariable("CI") == null; - return new Config + return new(targetOSName: GetTargetOSName(target), + compiler: compiler, + netFrameworkTarget: netFrameworkInfo.Name, + netFrameworkTargetVersion: netFrameworkInfo.Version, + installationMethod: _installMethodTask.Task.Wait(1000) ? _installMethodTask.Task.Result : Metric.Unknown(), + frameworkName: target == null ? Metric.Framework.UnityEditor : Metric.Framework.Unity, + frameworkVersion: Application.unityVersion) { - TargetOSName = GetTargetOSName(target), - Compiler = compiler, - NetFrameworkTarget = netFrameworkInfo.Name, - NetFrameworkTargetVersion = netFrameworkInfo.Version, AnalyticsCollection = analyticsEnabled ? AnalyticsCollection.Full : AnalyticsCollection.Disabled, - InstallationMethod = _installMethodTask.Task.Wait(1000) ? _installMethodTask.Task.Result : Metric.Unknown(), - FrameworkName = target == null ? Metric.Framework.UnityEditor : Metric.Framework.Unity, - FrameworkVersion = Application.unityVersion, TargetArchitecture = GetCpuArchitecture(target), TargetOsVersion = GetTargetOsVersion(target), TargetOsMinimumVersion = GetMinimumOsVersion(target), @@ -578,35 +575,35 @@ private static string GetCpuArchitecture(BuildTarget? buildTarget) { if (SystemInfo.processorType.IndexOf("ARM", StringComparison.OrdinalIgnoreCase) > -1) { - return Environment.Is64BitProcess ? CpuArchitecture.Arm64 : CpuArchitecture.Arm; + return Environment.Is64BitProcess ? Metric.CpuArchitecture.Arm64 : Metric.CpuArchitecture.Arm; } // Must be in the x86 family. - return Environment.Is64BitProcess ? CpuArchitecture.X64 : CpuArchitecture.X86; + return Environment.Is64BitProcess ? Metric.CpuArchitecture.X64 : Metric.CpuArchitecture.X86; } return buildTarget switch { - BuildTarget.iOS or BuildTarget.tvOS => CpuArchitecture.Arm64, + BuildTarget.iOS or BuildTarget.tvOS => Metric.CpuArchitecture.Arm64, BuildTarget.StandaloneOSX => EditorUserBuildSettings.GetPlatformSettings(BuildPipeline.GetBuildTargetName(buildTarget.Value), "Architecture") switch { - "ARM64" => CpuArchitecture.Arm64, - "x64" => CpuArchitecture.X64, - _ => CpuArchitecture.Universal, + "ARM64" => Metric.CpuArchitecture.Arm64, + "x64" => Metric.CpuArchitecture.X64, + _ => Metric.CpuArchitecture.Universal, }, - BuildTarget.StandaloneWindows => CpuArchitecture.X86, + BuildTarget.StandaloneWindows => Metric.CpuArchitecture.X86, BuildTarget.Android => PlayerSettings.Android.targetArchitectures switch { - AndroidArchitecture.ARMv7 => CpuArchitecture.Arm, - AndroidArchitecture.ARM64 => CpuArchitecture.Arm64, + AndroidArchitecture.ARMv7 => Metric.CpuArchitecture.Arm, + AndroidArchitecture.ARM64 => Metric.CpuArchitecture.Arm64, // These two don't have enum values in our Unity reference dll, but exist in newer versions // See https://github.com/Unity-Technologies/UnityCsReference/blob/70abf502c521c169ee8a302aa48c5600fc7c39fc/Editor/Mono/PlayerSettingsAndroid.bindings.cs#L14 - (AndroidArchitecture)(1 << 2) => CpuArchitecture.X86, - (AndroidArchitecture)(1 << 3) => CpuArchitecture.X64, - _ => CpuArchitecture.Universal, + (AndroidArchitecture)(1 << 2) => Metric.CpuArchitecture.X86, + (AndroidArchitecture)(1 << 3) => Metric.CpuArchitecture.X64, + _ => Metric.CpuArchitecture.Universal, }, - BuildTarget.StandaloneWindows64 or BuildTarget.StandaloneLinux64 or BuildTarget.XboxOne => CpuArchitecture.X64, + BuildTarget.StandaloneWindows64 or BuildTarget.StandaloneLinux64 or BuildTarget.XboxOne => Metric.CpuArchitecture.X64, _ => Metric.Unknown(), }; } diff --git a/Realm/Realm.Weaver/Analytics/Analytics.cs b/Realm/Realm.Weaver/Analytics/Analytics.cs index ce0e16a954..f0d2e7ccd3 100644 --- a/Realm/Realm.Weaver/Analytics/Analytics.cs +++ b/Realm/Realm.Weaver/Analytics/Analytics.cs @@ -528,19 +528,19 @@ public class Config public string? AnalyticsLogPath { get; init; } - required public string TargetOSName { get; init; } + public string TargetOSName { get; } - required public string NetFrameworkTarget { get; init; } + public string NetFrameworkTarget { get; } - required public string NetFrameworkTargetVersion { get; init; } + public string NetFrameworkTargetVersion { get; } - required public string InstallationMethod { get; init; } + public string InstallationMethod { get; } - required public string FrameworkName { get; init; } + public string FrameworkName { get; } - required public string FrameworkVersion { get; init; } + public string FrameworkVersion { get; } - required public string Compiler { get; init; } + public string Compiler { get; } // These are only available on Unity for now. public string TargetArchitecture { get; init; } = Metric.Unknown(); @@ -550,6 +550,24 @@ public class Config public string TargetOsMinimumVersion { get; init; } = Metric.Unknown(); public string? ProjectId { get; init; } + + public Config( + string targetOSName, + string netFrameworkTarget, + string netFrameworkTargetVersion, + string installationMethod, + string frameworkName, + string frameworkVersion, + string compiler) + { + TargetOSName = targetOSName; + NetFrameworkTarget = netFrameworkTarget; + NetFrameworkTargetVersion = netFrameworkTargetVersion; + InstallationMethod = installationMethod; + FrameworkName = frameworkName; + FrameworkVersion = frameworkVersion; + Compiler = compiler; + } } public enum AnalyticsCollection diff --git a/Realm/Realm/Realm.csproj b/Realm/Realm/Realm.csproj index 68558c0d1d..ad0411b79d 100644 --- a/Realm/Realm/Realm.csproj +++ b/Realm/Realm/Realm.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/Benchmarks/Benchmarks/Benchmarks.csproj b/Tests/Benchmarks/Benchmarks/Benchmarks.csproj index 7f3a14b198..8a240b50cc 100644 --- a/Tests/Benchmarks/Benchmarks/Benchmarks.csproj +++ b/Tests/Benchmarks/Benchmarks/Benchmarks.csproj @@ -5,7 +5,7 @@ true true enable - 11.0 + 10.0 portable diff --git a/Tests/Realm.Tests/Database/CollectionTests.cs b/Tests/Realm.Tests/Database/CollectionTests.cs index dc5cb75913..8bbad64ec7 100644 --- a/Tests/Realm.Tests/Database/CollectionTests.cs +++ b/Tests/Realm.Tests/Database/CollectionTests.cs @@ -1897,7 +1897,7 @@ public void Dict_Filter_WithRemappedProperty() var objects = dict.Filter($"{columnName} = $0", dict["a"]!.Id); Assert.That(objects.Count(), Is.EqualTo(1)); - Assert.That(objects.Single().Int, Is.EqualTo(dict["a"]!.Int)); + Assert.That(objects.Single()!.Int, Is.EqualTo(dict["a"]!.Int)); } } @@ -2180,4 +2180,4 @@ public partial class B : TestRealmObject { public IntPropertyObject? C { get; set; } } -} \ No newline at end of file +} diff --git a/Tests/Realm.Tests/Realm.Tests.csproj b/Tests/Realm.Tests/Realm.Tests.csproj index 6fc1bb8ebb..b40fbb0d5a 100644 --- a/Tests/Realm.Tests/Realm.Tests.csproj +++ b/Tests/Realm.Tests/Realm.Tests.csproj @@ -72,7 +72,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/Realm.Tests/Sync/FunctionsTests.cs b/Tests/Realm.Tests/Sync/FunctionsTests.cs index 857875ec59..5ba2f40434 100644 --- a/Tests/Realm.Tests/Sync/FunctionsTests.cs +++ b/Tests/Realm.Tests/Sync/FunctionsTests.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Concurrent; +using System.Globalization; using System.Linq; using MongoDB.Bson; using MongoDB.Bson.Serialization.Conventions; @@ -382,7 +383,7 @@ public void CallFunction_AndTestBsonValue_Double([ValueSource(nameof(DoubleTestC [Test] public void CallFunction_AndTestBsonValue_Decimal([ValueSource(nameof(DecimalTestCases))] decimal arg) { - if (arg == decimal.MinValue || arg == decimal.MaxValue) + if (arg is decimal.MinValue or decimal.MaxValue) { // MongoDB.Bson serializes MinValue/MaxValue as Decimal128.MinValue/MaxValue: // https://github.com/mongodb/mongo-csharp-driver/blob/b2668fb80c8d45be58a8009e336006c9545c1581/src/MongoDB.Bson/Serialization/Options/RepresentationConverter.cs#L153-L160 @@ -438,6 +439,8 @@ private void TestBsonValue(T val) { SyncTestHelpers.RunBaasTestAsync(async () => { + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; + var user = await GetUserAsync(); var result = await user.Functions.CallAsync("mirror", val); diff --git a/Tests/Realm.Tests/Sync/SessionTests.cs b/Tests/Realm.Tests/Sync/SessionTests.cs index 3986a6152d..09ca2d9146 100644 --- a/Tests/Realm.Tests/Sync/SessionTests.cs +++ b/Tests/Realm.Tests/Sync/SessionTests.cs @@ -878,8 +878,6 @@ public void Session_ConnectionState_FullFlow() { var config = await GetIntegrationConfigAsync(); using var realm = GetRealm(config); - var stateChanged = 0; - var completionTcs = new TaskCompletionSource(); var session = realm.SyncSession; session.Stop(); @@ -1114,7 +1112,6 @@ public void Session_ConnectionState_Propagated_Within_Multiple_Sessions() var config = await GetIntegrationConfigAsync(); using var realmA = GetRealm(config); using var realmB = GetRealm(config); - var stateChanged = 0; var sessionA = realmA.SyncSession; var sessionB = realmB.SyncSession; diff --git a/Tests/Realm.Tests/Sync/UserManagementTests.cs b/Tests/Realm.Tests/Sync/UserManagementTests.cs index 705e7194ee..bd6f7fa566 100644 --- a/Tests/Realm.Tests/Sync/UserManagementTests.cs +++ b/Tests/Realm.Tests/Sync/UserManagementTests.cs @@ -1094,7 +1094,7 @@ public void UserToStringOverride() Assert.That(user.ToString(), Does.Contain(user.Id)); } - [Test, Ignore("test")] + [Test] public void UserLogOut_RaisesChanged() { SyncTestHelpers.RunBaasTestAsync(async () => @@ -1107,7 +1107,7 @@ public void UserLogOut_RaisesChanged() try { Assert.That(s, Is.EqualTo(user)); - Assert.That(user.State, Is.EqualTo(UserState.Removed)); + Assert.That(user.State, Is.EqualTo(UserState.LoggedOut)); tcs.TrySetResult(); } catch (Exception ex) @@ -1124,7 +1124,7 @@ public void UserLogOut_RaisesChanged() }); } - [Test, Ignore("test")] + [Test] public void UserChanged_DoesntKeepObjectAlive() { SyncTestHelpers.RunBaasTestAsync(async () => @@ -1141,7 +1141,7 @@ public void UserChanged_DoesntKeepObjectAlive() }); } - [Test, Ignore("test")] + [Test] public void UserCustomDataChange_RaisesChanged() { var tcs = new TaskCompletionSource(); @@ -1152,8 +1152,6 @@ public void UserCustomDataChange_RaisesChanged() var collection = user.GetMongoClient("BackingDB").GetDatabase(SyncTestHelpers.RemoteMongoDBName()).GetCollection("users"); - var customDataId = ObjectId.GenerateNewId(); - var customDataDoc = new BsonDocument { ["_id"] = ObjectId.GenerateNewId(), diff --git a/Tools/DeployApps/DeployApps.csproj b/Tools/DeployApps/DeployApps.csproj index 0ec0752510..f36fa4f3ea 100644 --- a/Tools/DeployApps/DeployApps.csproj +++ b/Tools/DeployApps/DeployApps.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/global.json b/global.json new file mode 100644 index 0000000000..1c7274b725 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "7.0.100", + "rollForward": "latestFeature" + } +} \ No newline at end of file