Skip to content

Commit

Permalink
- Added the option to have in-memory compiled assembly to gain access…
Browse files Browse the repository at this point in the history
… to internals.
  • Loading branch information
TBN-MapleWheels committed Oct 25, 2023
1 parent 46a2fe1 commit 29338c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,13 @@ public AssemblyLoadingSuccessState LoadAssemblyPackages()

// try compile
successState = _assemblyManager.LoadAssemblyFromMemory(
pair.Key.Name.Replace(" ",""),
pair.Value.config.UseInternalAssemblyName ? "CompiledAssembly" : pair.Key.Name.Replace(" ",""),
syntaxTrees,
null,
CompilationOptions,
pair.Key.Name, ref id, pair.Value.config.UseNonPublicizedAssemblies ? null : publicizedAssemblies);
pair.Key.Name,
ref id,
pair.Value.config.UseNonPublicizedAssemblies ? null : publicizedAssemblies);

if (successState is not AssemblyLoadingSuccessState.Success)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Loader;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
// ReSharper disable ConditionIsAlwaysTrueOrFalse

[assembly: InternalsVisibleTo("CompiledAssembly")]

namespace Barotrauma;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public sealed class RunConfig
[XmlElement(ElementName = "UseNonPublicizedAssemblies")]
public bool UseNonPublicizedAssemblies { get; set; }

/// <summary>
/// If the mod includes source files, the compiled assembly will be named "CompiledAssembly" and have the [InternalVisibleTo()] attribute applied to it.
/// </summary>
[XmlElement(ElementName = "UseInternalAssemblyName")]
[DefaultValue(false)]
public bool UseInternalAssemblyName { get; set; }

[XmlElement(ElementName = "AutoGenerated")]
public bool AutoGenerated { get; set; }

Expand Down

0 comments on commit 29338c9

Please sign in to comment.