Skip to content

Commit e99e43c

Browse files
Migrate AppDomain.GetAssemblies() to CurrentAssemblies.GetLoadedAssemblies()
1 parent cc97131 commit e99e43c

File tree

7 files changed

+49
-0
lines changed

7 files changed

+49
-0
lines changed

Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using System.Collections.Generic;
55
using UnityEngine.Experimental.Rendering;
66
using System.Runtime.CompilerServices;
7+
#if UNITY_6000_5_OR_NEWER
8+
using UnityEngine.Assemblies;
9+
#endif
710

811
#if UNITY_EDITOR
912
using UnityEditor;
@@ -1349,7 +1352,11 @@ public static IEnumerable<Type> GetAllAssemblyTypes()
13491352
return s_AssemblyTypes;
13501353

13511354
var typeList = new List<Type>();
1355+
#if UNITY_6000_5_OR_NEWER
1356+
foreach (var assembly in CurrentAssemblies.GetLoadedAssemblies())
1357+
#else
13521358
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
1359+
#endif
13531360
{
13541361
try
13551362
{

Packages/com.unity.render-pipelines.core/Tests/Editor/ReflectionUtils.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Reflection;
6+
#if UNITY_6000_5_OR_NEWER
7+
using UnityEngine.Assemblies;
8+
#endif
69

710
namespace UnityEngine.Rendering.Tests
811
{
@@ -18,8 +21,12 @@ public static class ReflectionUtils
1821
/// <returns>The found type</returns>
1922
public static Type FindTypeByName(string name)
2023
{
24+
#if UNITY_6000_5_OR_NEWER
25+
var type = CurrentAssemblies.GetLoadedAssemblies()
26+
#else
2127
var type = AppDomain.CurrentDomain
2228
.GetAssemblies()
29+
#endif
2330
.Select(assembly => assembly.GetType(name))
2431
.FirstOrDefault(tt => tt != null);
2532

Packages/com.unity.render-pipelines.high-definition/Editor/Material/LTCAreaLight/LTCTableGeneratorEditor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using System.IO;
55
using UnityEditor;
66
using System.Linq;
7+
#if UNITY_6000_5_OR_NEWER
8+
using UnityEngine.Assemblies;
9+
#endif
710

811
namespace UnityEngine.Rendering.HighDefinition.LTC
912
{
@@ -35,7 +38,11 @@ static Type[] ListAllBRDFTypes()
3538
// This function lists all the classes that implement the interface IBSDF
3639
List<Type> types = new List<Type>();
3740
Type searchInterface = typeof(IBRDF);
41+
#if UNITY_6000_5_OR_NEWER
42+
return CurrentAssemblies.GetLoadedAssemblies()
43+
#else
3844
return AppDomain.CurrentDomain.GetAssemblies()
45+
#endif
3946
.SelectMany(s => s.GetTypes())
4047
.Where(p => searchInterface.IsAssignableFrom(p) && !p.IsInterface).ToArray();
4148
}

Packages/com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
using System.Reflection;
1414
using System.Runtime.Remoting.Metadata.W3cXsd2001;
1515
using UnityEditor.ProjectWindowCallback;
16+
#if UNITY_6000_5_OR_NEWER
17+
using UnityEngine.Assemblies;
18+
#endif
1619
using UnityEditor.ShaderGraph.Internal;
1720
using UnityEngine;
1821
using UnityEngine.Rendering;
@@ -336,7 +339,11 @@ static void Visit(List<AbstractMaterialNode> outputList, Dictionary<string, Abst
336339
if (s_LegacyTypeRemapping == null)
337340
{
338341
s_LegacyTypeRemapping = new Dictionary<SerializationHelper.TypeSerializationInfo, SerializationHelper.TypeSerializationInfo>();
342+
#if UNITY_6000_5_OR_NEWER
343+
foreach (var assembly in CurrentAssemblies.GetLoadedAssemblies())
344+
#else
339345
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
346+
#endif
340347
{
341348
foreach (var type in assembly.GetTypesOrNothing())
342349
{

Packages/com.unity.shadergraph/Editor/Data/Util/SerializationHelper.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using System.Reflection;
55
using UnityEditor.ShaderGraph.Serialization;
66
using UnityEngine;
7+
#if UNITY_6000_5_OR_NEWER
8+
using UnityEngine.Assemblies;
9+
#endif
710

811
namespace UnityEditor.Graphing
912
{
@@ -52,7 +55,11 @@ static Type GetTypeFromSerializedString(TypeSerializationInfo typeInfo)
5255
if (!typeInfo.IsValid())
5356
return null;
5457

58+
#if UNITY_6000_5_OR_NEWER
59+
var assemblies = CurrentAssemblies.GetLoadedAssemblies();
60+
#else
5561
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
62+
#endif
5663
foreach (var assembly in assemblies)
5764
{
5865
var type = assembly.GetType(typeInfo.fullName);

Packages/com.unity.shadergraph/Editor/Drawing/Inspector/MasterPreviewView.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
using UnityEditor.UIElements;
1212
using UnityEngine.UIElements;
13+
#if UNITY_6000_5_OR_NEWER
14+
using UnityEngine.Assemblies;
15+
#endif
1316

1417
namespace UnityEditor.ShaderGraph.Drawing.Inspector
1518
{
@@ -42,7 +45,11 @@ public VisualElement preview
4245
}
4346

4447
List<string> m_DoNotShowPrimitives = new List<string>(new string[] { PrimitiveType.Plane.ToString() });
48+
#if UNITY_6000_5_OR_NEWER
49+
static Type s_ObjectSelector = CurrentAssemblies.GetLoadedAssemblies().SelectMany(x => x.GetTypesOrNothing()).FirstOrDefault(t => t.FullName == "UnityEditor.ObjectSelector");
50+
#else
4551
static Type s_ObjectSelector = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypesOrNothing()).FirstOrDefault(t => t.FullName == "UnityEditor.ObjectSelector");
52+
#endif
4653

4754
public string assetName
4855
{

Packages/com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
using UnityEditor.ShaderGraph.Serialization;
1414
using UnityEngine.UIElements;
1515
using Edge = UnityEditor.Experimental.GraphView.Edge;
16+
#if UNITY_6000_5_OR_NEWER
17+
using UnityEngine.Assemblies;
18+
#endif
1619
using Node = UnityEditor.Experimental.GraphView.Node;
1720
using UnityEngine.Pool;
1821

@@ -38,7 +41,11 @@ public MaterialGraphView()
3841

3942
// Get reference to GraphView assembly
4043
Assembly graphViewAssembly = null;
44+
#if UNITY_6000_5_OR_NEWER
45+
foreach (var assembly in CurrentAssemblies.GetLoadedAssemblies())
46+
#else
4147
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
48+
#endif
4249
{
4350
var assemblyName = assembly.GetName().ToString();
4451
if (assemblyName.Contains("GraphView"))

0 commit comments

Comments
 (0)