Skip to content

Commit c50deb3

Browse files
authored
Deprecate ModuleScope.DefineType (#445)
* Deprecate `ModuleScope.DefineType` * Update public API contract
1 parent 57b068e commit c50deb3

7 files changed

Lines changed: 9 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Deprecations:
1414
- `Castle.Core.Internal.Lock` (class)
1515
- `Castle.Core.Internal.ILockHolder` (interface)
1616
- `Castle.Core.Internal.IUpgradeableLockHolder` (interface)
17+
- You should no longer manually emit types into DynamicProxy's dynamic assembly. For this reason, the following member has been deprecated. (@stakx, #445)
18+
- `Castle.DynamicProxy.ModuleScope.DefineType` (method)
1719
- The proxy type cache in `ModuleScope` should no longer be accessed directly. For this reason, the members listed below have been deprecated. (@stakx, #391)
1820
- `Castle.DynamicProxy.ModuleScope.Lock` (property)
1921
- `Castle.DynamicProxy.ModuleScope.GetFromCache` (method)

ref/Castle.Core-net35.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,7 @@ public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule, Castle.D
26472647
public System.Reflection.Emit.ModuleBuilder WeakNamedModule { get; }
26482648
public string WeakNamedModuleDirectory { get; }
26492649
public string WeakNamedModuleName { get; }
2650+
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
26502651
public System.Reflection.Emit.TypeBuilder DefineType(bool inSignedModulePreferably, string name, System.Reflection.TypeAttributes flags) { }
26512652
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
26522653
public System.Type GetFromCache(Castle.DynamicProxy.Generators.CacheKey key) { }

ref/Castle.Core-net40.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,7 @@ public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule, Castle.D
26942694
public System.Reflection.Emit.ModuleBuilder WeakNamedModule { get; }
26952695
public string WeakNamedModuleDirectory { get; }
26962696
public string WeakNamedModuleName { get; }
2697+
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
26972698
public System.Reflection.Emit.TypeBuilder DefineType(bool inSignedModulePreferably, string name, System.Reflection.TypeAttributes flags) { }
26982699
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
26992700
public System.Type GetFromCache(Castle.DynamicProxy.Generators.CacheKey key) { }

ref/Castle.Core-net45.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,7 @@ public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule, Castle.D
26942694
public System.Reflection.Emit.ModuleBuilder WeakNamedModule { get; }
26952695
public string WeakNamedModuleDirectory { get; }
26962696
public string WeakNamedModuleName { get; }
2697+
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
26972698
public System.Reflection.Emit.TypeBuilder DefineType(bool inSignedModulePreferably, string name, System.Reflection.TypeAttributes flags) { }
26982699
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
26992700
public System.Type GetFromCache(Castle.DynamicProxy.Generators.CacheKey key) { }

ref/Castle.Core-netstandard1.3.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule, Castle.D
15431543
public string StrongNamedModuleName { get; }
15441544
public System.Reflection.Emit.ModuleBuilder WeakNamedModule { get; }
15451545
public string WeakNamedModuleName { get; }
1546+
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
15461547
public System.Reflection.Emit.TypeBuilder DefineType(bool inSignedModulePreferably, string name, System.Reflection.TypeAttributes flags) { }
15471548
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
15481549
public System.Type GetFromCache(Castle.DynamicProxy.Generators.CacheKey key) { }

ref/Castle.Core-netstandard1.5.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule, Castle.D
15431543
public string StrongNamedModuleName { get; }
15441544
public System.Reflection.Emit.ModuleBuilder WeakNamedModule { get; }
15451545
public string WeakNamedModuleName { get; }
1546+
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
15461547
public System.Reflection.Emit.TypeBuilder DefineType(bool inSignedModulePreferably, string name, System.Reflection.TypeAttributes flags) { }
15471548
[System.ObsoleteAttribute("Exposes a component that is intended for internal use only.")]
15481549
public System.Type GetFromCache(Castle.DynamicProxy.Generators.CacheKey key) { }

src/Castle.Core/DynamicProxy/ModuleScope.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ public void LoadAssemblyIntoCache(Assembly assembly)
573573
}
574574
#endif
575575

576+
[Obsolete("Exposes a component that is intended for internal use only.")] // TODO: Redeclare this method as `internal`.
577+
[EditorBrowsable(EditorBrowsableState.Never)]
576578
public TypeBuilder DefineType(bool inSignedModulePreferably, string name, TypeAttributes flags)
577579
{
578580
var module = ObtainDynamicModule(disableSignedModule == false && inSignedModulePreferably);

0 commit comments

Comments
 (0)