From 19b4fcabe82934b2f49bfadc0ae28d85680d4ca0 Mon Sep 17 00:00:00 2001 From: PETS automation <299490404+pets-svc[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 15:59:57 +0200 Subject: [PATCH 1/2] trunk shadow changes: com.unity.mobile.android-logcat [skip ci] --- .../Tests/Editor/AndroidLogcatNetTests.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs index 83bb435e..01ce49cd 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs @@ -6,7 +6,7 @@ using NUnit.Framework; using UnityEditor; using UnityEditor.Compilation; -using Assembly = System.Reflection.Assembly; +using Unity.Android.Logcat; class AndroidLogcatNetTests { @@ -32,14 +32,14 @@ private UnityEditor.Compilation.Assembly GetLogcatAssembly() [Test] public void ValidateAssemblyReferences() { - var logcatAssembly = GetLogcatAssembly(); - var expectedReferences = new List(new[] { "mscorlib", "System", "System.Xml.Linq", "UnityEngine.IMGUIModule", + "UnityEngine.ScriptingModule", + "UnityEngine.UICommonModule", "UnityEngine.CoreModule", "UnityEngine.VideoModule", "UnityEngine.TextRenderingModule", @@ -48,11 +48,13 @@ public void ValidateAssemblyReferences() "UnityEngine.ImageConversionModule", "UnityEngine.JSONSerializeModule", "UnityEditor.CoreModule", + "Unity.Scripting", }); var referencedCount = expectedReferences.ToDictionary(s => s, s => 0); - var references = Assembly.ReflectionOnlyLoadFrom(logcatAssembly.outputPath).GetReferencedAssemblies().Select(a => a.Name); + // ReflectionOnlyLoadFrom is unsupported on CoreCLR; inspect the loaded assembly instead. + var references = typeof(AndroidLogcatConsoleWindow).Assembly.GetReferencedAssemblies().Select(a => a.Name); foreach (var r in references) { Assert.Contains(r, expectedReferences, $"Unexpected reference '{r}'"); From 767b846ce68b370bbe91c5288bcaedf4519b9885 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 30 Oct 2026 10:25:18 +0200 Subject: [PATCH 2/2] revert assembly checks --- .../Tests/Editor/AndroidLogcatNetTests.cs | 82 ++++++++++++++----- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs index 01ce49cd..45e5d2d0 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatNetTests.cs @@ -1,12 +1,13 @@ +using NUnit.Framework; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; -using NUnit.Framework; +using Unity.Android.Logcat; using UnityEditor; using UnityEditor.Compilation; -using Unity.Android.Logcat; class AndroidLogcatNetTests { @@ -32,39 +33,71 @@ private UnityEditor.Compilation.Assembly GetLogcatAssembly() [Test] public void ValidateAssemblyReferences() { + var logcatAssembly = GetLogcatAssembly(); + + static bool IsFrameworkReference(string name) => + name == "mscorlib" || name == "netstandard" || name == "System" || name.StartsWith("System.", StringComparison.Ordinal); + var expectedReferences = new List(new[] { - "mscorlib", - "System", - "System.Xml.Linq", "UnityEngine.IMGUIModule", - "UnityEngine.ScriptingModule", - "UnityEngine.UICommonModule", "UnityEngine.CoreModule", "UnityEngine.VideoModule", "UnityEngine.TextRenderingModule", "UnityEngine.UIElementsModule", - "System.Core", "UnityEngine.ImageConversionModule", "UnityEngine.JSONSerializeModule", - "UnityEditor.CoreModule", - "Unity.Scripting", + "UnityEditor.CoreModule" + }); +#if UNITY_6000_1_OR_NEWER + // While running tests in Yamato in logcat package, the active build target is Android + // But in unity/unity it's not Android... + // That's why we expect this reference conditionally + if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) + { + expectedReferences.AddRange(new[] + { + "UnityEditor.Android.Extensions" + }); + }; +#endif +#if UNITY_6000_5_OR_NEWER + expectedReferences.AddRange(new[] + { + "Unity.Scripting" }); +#endif + +#if UNITY_6000_7_OR_NEWER + expectedReferences.AddRange(new[] + { + "UnityEngine.ScriptingModule", + "UnityEngine.UICommonModule", + }); +#endif var referencedCount = expectedReferences.ToDictionary(s => s, s => 0); // ReflectionOnlyLoadFrom is unsupported on CoreCLR; inspect the loaded assembly instead. + var references = typeof(AndroidLogcatConsoleWindow).Assembly.GetReferencedAssemblies().Select(a => a.Name); - foreach (var r in references) + var errors = new StringBuilder(); + Console.WriteLine($"Logcat package references:\n{string.Join("\n", references)}"); + foreach (var r in references.Where(n => !IsFrameworkReference(n))) { - Assert.Contains(r, expectedReferences, $"Unexpected reference '{r}'"); - referencedCount[r]++; + if (!expectedReferences.Contains(r)) + errors.AppendLine($"Unexpected reference '{r}'"); + else + referencedCount[r]++; } foreach (var r in referencedCount) { - Assert.AreEqual(1, r.Value, $"'{r.Key}' was expected to be referenced once, but was referenced {r.Value} times, please adjust expectations, maybe the reference is no longer needed?"); + if (r.Value != 1) + errors.AppendLine($"'{r.Key}' was expected to be referenced once, but was referenced {r.Value} times, please adjust expectations, maybe the reference is no longer needed?"); } + + Assert.AreEqual(0, errors.Length, errors.ToString()); } /// @@ -76,13 +109,21 @@ public void ValidateAssemblyReferences() public void ValidateUsingStatements() { var logcatAssembly = GetLogcatAssembly(); - var usingStatementRegex = new Regex(@"using\s+(?[a-zA-Z]+)\.*\S*;"); + var usingStatementRegex = new Regex(@"using\s+(?(?[a-zA-Z]+)\.*\S*);"); - var expectedNamespaces = new[] + // Any namespace under these roots is allowed + var expectedRootNamespaces = new[] { "UnityEditor", "UnityEngine", - "System" + "System", + }; + + // Only these exact namespaces are allowed + var expectedNamespaces = new[] + { + "Unity.Profiling", + "Unity.Scripting.LifecycleManagement", }; var errors = new StringBuilder(); @@ -92,10 +133,11 @@ public void ValidateUsingStatements() var result = usingStatementRegex.Matches(contents); foreach (Match r in result) { - var namezpace = r.Groups["RootNamespace"].Value; - if (!expectedNamespaces.Contains(namezpace)) + var rootNamespace = r.Groups["RootNamespace"].Value; + var namezpace = r.Groups["Namespace"].Value; + if (!expectedRootNamespaces.Contains(rootNamespace) && !expectedNamespaces.Contains(namezpace)) { - errors.AppendLine($"Unexpected 'using {namezpace}...;' in {file}"); + errors.AppendLine($"Unexpected 'using {namezpace};' in {file}"); } } }