public void StateRepresentationAssemblyIsCompiled() { var paths = new List <string>(); paths.AddRange(m_TraitsCodeGenerator.Generate(k_OutputPath, m_EnumDefinition)); paths.AddRange(m_TraitsCodeGenerator.Generate(k_OutputPath, m_TraitDefinition)); paths.AddRange(m_CodeGenerator.GenerateStateRepresentation(k_OutputPath)); Assert.IsTrue(File.Exists(Path.Combine(k_OutputPath, TypeHelper.StateRepresentationQualifier, "PlanA", "PlanStateRepresentation.cs"))); var stateRepresentationAssemblyPath = Path.Combine(k_OutputPath, $"{TypeHelper.StateRepresentationQualifier}.dll"); Assert.IsTrue(PlannerAssemblyBuilder.BuildAssembly(paths.ToArray(), stateRepresentationAssemblyPath)); }
public void PlansAssemblyIsCompiled() { var stateRepresentationAssemblyPath = Path.Combine(k_OutputPath, $"{TypeHelper.StateRepresentationQualifier}.dll"); // Reference .cs files from Unity.AI.Planner.Editor.CustomMethods.Tests assembly definition var assemblyReference = AssetDatabase.FindAssets($"t: {nameof(AssemblyDefinitionAsset)}"); var paths = new List <string>(); foreach (var asmRefGuid in assemblyReference) { var assetPath = AssetDatabase.GUIDToAssetPath(asmRefGuid); if (assetPath.Contains("Unity.AI.Planner.Editor.Tests.CustomMethods.asmdef")) { PlannerAssemblyBuilder.ReferenceSourceFromAssetPath(assetPath, paths); break; } } var additionalReferences = new List <string>(); additionalReferences.Add(stateRepresentationAssemblyPath); var customAssemblyPath = Path.Combine(k_OutputPath, $"{TypeHelper.CustomAssemblyName}.dll"); Assert.IsTrue(PlannerAssemblyBuilder.BuildAssembly(paths.ToArray(), customAssemblyPath, additionalReferences: additionalReferences.ToArray())); // Pre-load referenced assemblies in the reflection context System.Reflection.Assembly.ReflectionOnlyLoadFrom(stateRepresentationAssemblyPath); foreach (var reference in PlannerAssemblyBuilder.predefinedReferences) { System.Reflection.Assembly.ReflectionOnlyLoadFrom(reference); } AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += PlannerAssemblyBuilder.ResolveReflectionAssemblyDependency; var customAssembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom(customAssemblyPath); additionalReferences.Add(customAssemblyPath); paths = m_CodeGenerator.GeneratePlans(k_OutputPath, customAssembly); Assert.IsTrue(File.Exists(Path.Combine(k_OutputPath, TypeHelper.PlansQualifier, "PlanA", "ActionScheduler.cs"))); Assert.IsTrue(File.Exists(Path.Combine(k_OutputPath, TypeHelper.PlansQualifier, "PlanA", "ActionA.cs"))); Assert.IsTrue(File.Exists(Path.Combine(k_OutputPath, TypeHelper.PlansQualifier, "PlanA", "TerminationA.cs"))); Assert.IsTrue(PlannerAssemblyBuilder.BuildAssembly(paths.ToArray(), Path.Combine(k_OutputPath, $"{TypeHelper.PlansQualifier}.dll"), additionalReferences: additionalReferences.ToArray())); }