我们最近从PostSharp 3.0.37升级到3.1.48。从那时起,我们的自定义MethodInterceptionAspect不再在构建服务器上添加Initalize()方法(通过CompileTimeInitialize)。奇怪的是,PostSharp在VisualStudio中创建的dll具有预期的初始化代码。
根据PostSharp发布文档,两个版本之间没有任何安装更改。
我们在源代码管理中包含许可证密钥。
以前有人遇到过这个吗?
编辑:
示例编译时初始化代码:
public abstract class BaseMethodInterceptionAspect : MethodInterceptionAspect
{
protected bool IsAsync { get; set; }
public override void CompileTimeInitialize(MethodBase method, AspectInfo aspectInfo)
{
var methodInfo = method as MethodInfo;
if (methodInfo == null)
{
throw new Exception("MethodInfo is null");
}
IsAsync = typeof(Task).IsAssignableFrom(methodInfo.ReturnType);
base.CompileTimeInitialize(method, aspectInfo);
}
public sealed override void OnInvoke(MethodInterceptionArgs args)
{
if (!IsAsync)
{
// do one thing
}
else
{
// do another
}
}
}
在反编译其中一个使用方面的程序集(TypedLoggerShimFactory)时,缺少构建服务器DLL:
[System.Runtime.CompilerServices.CompilerGenerated]
static TypedLoggerShimFactory()
{
<>z__a_18.Initialize();
}
编辑2: PostSharp在有问题的汇编上运行:
[PostSharp30] C:\ ProgramData \ PostSharp \ 3.1.58 \ bin.Release \ postsharp.4.0-x86.exe obj \ Release \ Before-PostSharp \ Iwi.Platform.WCFServiceManager.dll / X:默认 / NOLOGO /P:Output=C:\BuildAgent\work\67a99d05742f768a\Iwi.Platform.WCFServiceManager\obj\Release\Iwi.Platform.WCFServiceManager.dll /P:ReferenceDirectory=C:\BuildAgent\work\67a99d05742f768a\Iwi.Platform.WCFServiceManager / P:配置=推出 / P:平台= AnyCPU
&#34; / P:SearchPath = .. \ bin \ Release \ | obj \ Release \ | C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ | C: \ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ Facades \&#34; / P:IntermediateDirectory = obj \ Release \ PostSharp / P:CleanIntermediate = False /P:MSBuildProjectFullPath=C:\BuildAgent\work\67a99d05742f768a\Iwi.Platform.Library\Iwi.Platform.Library.csproj / P:SignAssembly = False / P:PrivateKeyLocation = / P:PrivateKeyContai ...
谢谢,