Visual studio 2013 PostSharp在构建时在VS 2015中抛出错误,但在VS 2013中没有抛出错误

Visual studio 2013 PostSharp在构建时在VS 2015中抛出错误,但在VS 2013中没有抛出错误,visual-studio-2013,visual-studio-2015,postsharp,Visual Studio 2013,Visual Studio 2015,Postsharp,我有一个WPF的企业级解决方案,包含多个项目。代码在VS 2013中构建良好,在VS 2015中代码没有构建 我试过: 删除受影响的项目并调整代码以观察它就是这个项目。是的 我尝试使用NuGet管理器删除“PostSharp”、“PostSharp.Patterns.Common”、“PostSharp.Patterns.Model”的PostSharp引用;重建,重新启动VS,从Nuget获取最新版本。同样的例外 我尝试升级所有其他项目。同样的故事 在解决方案中,我还引用了MS.提到的“Pri

我有一个WPF的企业级解决方案,包含多个项目。代码在VS 2013中构建良好,在VS 2015中代码没有构建

我试过:

  • 删除受影响的项目并调整代码以观察它就是这个项目。是的
  • 我尝试使用NuGet管理器删除“PostSharp”、“PostSharp.Patterns.Common”、“PostSharp.Patterns.Model”的PostSharp引用;重建,重新启动VS,从Nuget获取最新版本。同样的例外
  • 我尝试升级所有其他项目。同样的故事
  • 在解决方案中,我还引用了MS.提到的“Prism”和“Unity”。问题是,我甚至不知道发生这种情况的“位置”,我只是瞎了眼,因为堆栈跟踪错误只提到了项目,而不是引用“PostSharp”命名空间以外的特定类或位置。这是:

    'Severity   Code    Description Project File    Line    Suppression State
    Error       An unexpected exception occurred when executing user code: System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeConstructorInfo' to type 'System.Reflection.MethodInfo'.
       at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.PropertiesDependenciesAnalyzer.MethodAnalyzer.TryGetDependsOn(IMethodCallExpression expression, List`1& invocationPaths, List`1& messages)
       at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.PropertiesDependenciesAnalyzer.MethodAnalyzer.VisitMethodCallExpression(IMethodCallExpression expression)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitSyntaxElement(ISyntaxElement syntaxElement)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitStatementExpression(IStatementExpression statementExpression)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitSyntaxElement(ISyntaxElement syntaxElement)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitBlockExpression(IBlockExpression instructionBlock)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitSyntaxElement(ISyntaxElement syntaxElement)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitBlockExpression(IBlockExpression instructionBlock)
       at PostSharp.Reflection.Syntax.SyntaxTreeVisitor.VisitMethodBody(ISyntaxMethodBody methodBody)
       at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.PropertiesDependenciesAnalyzer.MethodAnalyzer.AnalyzeMethodRecursive(MethodBase method)
       at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.PropertiesDependenciesAnalyzer.MethodAnalyzer.AnalyzeProperty(Type type, PropertyInfo propertyInfo, ExplicitDependencyMap currentTypeExplicitDependencyMap)
       at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.PropertiesDependenciesAnalyzer.AnalyzeType(Type type)
       at PostSharp.Patterns.Model.NotifyPropertyChangedAttribute.CompileTimeInitialize(Type type, AspectInfo aspectInfo)
       at PostSharp.Sdk.AspectWeaver.AspectWeavers.TypeLevelAspectWeaverInstance.^RDzfO2to.^XTF+fjOj()
       at PostSharp.Sdk.Utilities.ExceptionHelper.ExecuteUserCode(MessageLocation messageLocation, Action userCode, Type[] acceptableExceptions).   Namespace.Project D:\TFS\SourceCodeLocation\POSTSHARP
    

    事实证明,这是一件非常简单的事情,VS 2013和2015在编译选项“strict”设置为on的情况下也允许这样做,但PostSharp不允许这样做

    Private _DateDeactivated As Nullable(Of Date)
    
    <SafeForDependencyAnalysis>
    Public Property DateDeactivated As Nullable(Of Date)
      Get
        If MyRequest.DateDeactivated.HasValue Then
          IsDeactivated = True
            Return MyRequest.DateDeactivated.Value
          Else
            Return New Nullable(Of Date)
          End If
        End Get
      Set(value As Nullable(Of Date))
        _DateDeactivated = value
      End Set
    End Property
    
    应该是:

    Return MyRequest.DateDeactivated
    

    这不是我的代码,而是导致一个更大的解决方案无法在VS 2015中使用PostSharp编译。我更担心的是PostSharp无法提供实际文件的参考。我用蛮力找到了答案,只是浏览了文件,注释了属性和方法,直到构建成功,然后浏览了文件,发现了问题所在。可能有更好的验证工具,比如ReSharper,可能已经捕获了它,但它可以工作。这可能会对某些人有所帮助,但可能不会。

    事实证明,这是一件非常简单的事情,VS 2013和2015在某种程度上允许了这一点,即使编译选项“strict”设置为on,但PostSharp不会

    Private _DateDeactivated As Nullable(Of Date)
    
    <SafeForDependencyAnalysis>
    Public Property DateDeactivated As Nullable(Of Date)
      Get
        If MyRequest.DateDeactivated.HasValue Then
          IsDeactivated = True
            Return MyRequest.DateDeactivated.Value
          Else
            Return New Nullable(Of Date)
          End If
        End Get
      Set(value As Nullable(Of Date))
        _DateDeactivated = value
      End Set
    End Property
    
    应该是:

    Return MyRequest.DateDeactivated
    

    这不是我的代码,而是导致一个更大的解决方案无法在VS 2015中使用PostSharp编译。我更担心的是PostSharp无法提供实际文件的参考。我用蛮力找到了答案,只是浏览了文件,注释了属性和方法,直到构建成功,然后浏览了文件,发现了问题所在。可能有更好的验证工具,比如ReSharper,可能已经捕获了它,但它可以工作。这可能对某些人有帮助,但可能没有。

    这是
    [NotifyPropertyChanged]
    方面的一个错误,应该在4.2.26和4.3.9版中修复。如果不是这样,请告诉我


    问题在于VB编译器生成IL代码以处理
    可为null的
    -对属性依赖关系的分析根本没有预料到这一点。

    这是
    [NotifyPropertyChanged]
    方面的一个错误,应该在4.2.26和4.3.9版中修复。如果不是这样,请告诉我

    问题在于VB编译器生成IL代码以处理
    Nullable
    ——对属性依赖关系的分析根本没有想到这一点