gpt4 book ai didi

enums - Obfuscar SkipType 配置元素不适用于枚举

转载 作者:行者123 更新时间:2023-12-04 00:31:57 24 4
gpt4 key购买 nike

Obfuscar SkipType配置元素似乎不适用于枚举。这是我的最小配置文件。

<?xml version="1.0"?>
<configuration>

<startup><supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>

<Obfuscator>

<Var name="InPath"
value="\users\user\docs\vs2013\projects\wpfapp\wpfapp\bin\debug" />
<Var name="OutPath"
value="\users\user\docs\vs2013\projects\wpfapp\wpfapp\bin\debug" />

<Module file="$(InPath)\wpfapp.exe" />

<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="true" />

<SkipType name="WpfApp.Category" skipFields="true" skipProperties="true" />

</Obfuscator>

</configuration>

映射输出文件显示跳过无效,枚举类型 Category已重命名。

Renamed Types:

[WpfApp]WpfApp.Category -> [WpfApp]A.a
{
WpfApp.Category [WpfApp]WpfApp.Category WpfApp.Category::Low -> A
WpfApp.Category [WpfApp]WpfApp.Category WpfApp.Category::High -> a

System.Int32 [WpfApp]System.Int32 WpfApp.Category::value__ skipped: special name
}

编辑元素<SkipType name="WpfApp.Category" />导致同样的问题。

编辑元素<SkipType name="WpfApp.Category" skipFields="true" />导致同样的问题。

编辑元素<SkipField type="WpfApp.Category" name="*" />导致同样的问题。

编辑:这对

<SkipField type="WpfApp.Category" name="Low" />

<SkipField type="WpfApp.Category" name="High" />导致同样的问题。

来源:

namespace WpfApp
{
public enum Category { Low, High }

//[System.Reflection.Obfuscation]
public partial class MainWindow : Window
{
private ViewModel ViewModel;

public MainWindow()
{
InitializeComponent();
this.DataContext = this.ViewModel = new ViewModel();
}

private void MyButtonClick(object sender, RoutedEventArgs e)
{
this.ViewModel.Process(MyTextBox.Text);
}
}

internal class ViewModel : WpfNotifier
{
private const float DefaultKilograms = 80.0f;

private string _kilograms;
public string Kilograms // WPF binds here
{
get { return this._kilograms; }
set { this._kilograms = value; NotifyPropertyChanged(); }
}
private string _resultText;
public string ResultText // WPF binds here
{
get { return this._resultText; }
set { this._resultText = value; NotifyPropertyChanged(); }
}

internal void Process(string input)
{
float kilograms;
if (Single.TryParse(input, out kilograms))
{
Category c = (kilograms > 100.0f) ? Category.High : Category.Low;
this.ResultText = c.ToString();
}
else
{
this.Kilograms = ViewModel.DefaultKilograms.ToString();
}
}
}

public class WpfNotifier : INotifyPropertyChanged
{
[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged; // public for interface

internal void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
else
; // it is harmless to fail to notify before the window has been loaded and rendered
}
}
}

这是错误还是我的用法有误?

最佳答案

你的用法是错误的。如果你检查 the documentation你会看到 <SkipType>标签必须放入 <Module>标签。否则,Obfuscar 不知道此跳过规则在哪个模块/程序集中生效。所以你应该试试

<Module file="$(InPath)\wpfapp.exe">
<SkipType name="WpfApp.Category" skipFields="true" skipProperties="true" />
</Module>

关于enums - Obfuscar SkipType 配置元素不适用于枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27941434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com