簡體   English   中英

從合並的庫重命名類型

[英]Renaming type from merged library

在主庫中有一個命名空間Main.TargetNamespace 在合並的庫中,存在一個公共類型Merged.SourceNamespace.Type

我需要將類型Merged.SourceNamespace.Type移至Main.TargetNamespace作為public

我做了

[assembly: Obfuscation(Feature = "ilmerge custom parameters: /internalize:exclude.file", Exclude = false)]
[assembly: Obfuscation(Feature = "Apply to type Merged.SourceNamespace.Type: type renaming pattern Main.TargetNamespace.Type", Exclude = false)]

但是僅禁用內部化(即,第一行有效): Merged.SourceNamespace.Type類型是公共的,並且在混淆程序Merged.SourceNamespace.Type可用。

如何使合並庫中的類型Merged.SourceNamespace.Type保持公共狀態並將其移至指定的命名空間Main.TargetNamespace.Type

為了使Merged.SourceNamespace.Type保持公共狀態,應將其從內部化中排除:

namespace Merged.SourceNamespace
{
    [Obfuscation(Feature = "internalization", Exclude = true)]
    public class Type
    {
        // ...
    }
}

Main程序集的相應混淆設置應如下所示:

[assembly: Obfuscation(Feature = "merge with Merged.dll", Exclude = false)]
[assembly: Obfuscation(Feature = "Apply to type Merged.SourceNamespace.Type: type renaming pattern Main.TargetNamespace.Type", Exclude = false)]

PS:一般性建議。 雖然給定的配方可以實現目標,但我強烈建議避免在生產方案中使用它。 原因如下:程序集的公共API應該由源代碼專門定義。 不要依賴Eazfuscator.NET之類的工具來為您進行API轉換。 否則,事情很快就會變得多毛。 例如,您的同事或未來的您可能很難理解該API的運行情況,以及為什么它取決於混淆。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM