Project suddenly fails to compile.

henry.nordstrom's Avatar

henry.nordstrom

31 Jul, 2017 03:08 AM

The system does not point out the source file or line which fails to compile.

16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): warning PS0262: PostSharp encountered some recoverable errors while parsing the pdb file of MyCashFlowIntegration.exe. The debugging experience may be affected.
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: An unexpected exception occurred when executing user code: System.InvalidOperationException: Operation is not valid due to the current state of the object.
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.Expression.^42TMFDL72M3v(IMethodBodyElement _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^5RpPD6cW.VisitSyntaxElement(IMethodBodyElement _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitFieldExpression(IFieldExpression expression)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitSyntaxElement(IMethodBodyElement syntaxElement)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^5RpPD6cW.VisitSyntaxElement(IMethodBodyElement _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitBinaryExpression(IBinaryExpression expression)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitSyntaxElement(IMethodBodyElement syntaxElement)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^5RpPD6cW.VisitSyntaxElement(IMethodBodyElement _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitStatementExpression(IStatementExpression statementExpression)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitSyntaxElement(IMethodBodyElement syntaxElement)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^5RpPD6cW.VisitSyntaxElement(IMethodBodyElement _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitBlockExpression(IBlockExpression instructionBlock)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitSyntaxElement(IMethodBodyElement syntaxElement)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^5RpPD6cW.VisitSyntaxElement(IMethodBodyElement _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitBlockExpression(IBlockExpression instructionBlock)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Reflection.MethodBody.MethodBodyVisitor.VisitMethodBody(IMethodBody methodBody)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^5RpPD6cW.VisitMethodBody(IMethodBody _0)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxMethodBody.^pFnf8wEt()
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxService.GetMethodBody(MethodDefDeclaration method, MethodBodyAbstractionLevel abstractionLevel)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.CodeModel.Syntax.SyntaxService.GetMethodBody(MethodBase method, MethodBodyAbstractionLevel abstractionLevel)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.PropertiesDependenciesAnalyzer.AnalyzeType(Type type)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Patterns.Model.NotifyPropertyChangedAttribute.CompileTimeInitialize(Type type, AspectInfo aspectInfo)
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.AspectWeaver.AspectWeavers.TypeLevelAspectWeaverInstance.^gAHJKdyo.^WnalpwzH()
16>C:\Users\henry\Documents\Visual Studio 2015\Projects\Current\MCfIntegration2015\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0125: at PostSharp.Sdk.Utilities.ExceptionHelper.ExecuteUserCode(MessageLocation messageLocation, Action userCode, Type[] acceptableExceptions).
========== Rebuild All: 15 succeeded, 2 failed, 0 skipped ==========

  1. 1 Posted by henry.nordstrom on 31 Jul, 2017 03:23 AM

    henry.nordstrom's Avatar

    ...I had been using version 5.0.30 on this solution for a while and it worked fine.

  2. 2 Posted by henry.nordstrom on 31 Jul, 2017 04:17 PM

    henry.nordstrom's Avatar

    This is very similar to the problem I reported with .5.0.28. Please see the following snippet.

    ====

    /*

    TRYING TO COMPILE THE FOLLOWING CODE RESULTS IN:

    "An unexpected exception occurred when executing user code: System.InvalidOperationException:
    Operation is not valid due to the current state of the object...
    ...at PostSharp.Sdk.Utilities.ExceptionHelper.ExecuteUserCode(MessageLocation messageLocation,
    Action userCode, Type[] acceptableExceptions)."

    */

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using PostSharp.Patterns.Model;

    namespace PostSharp_5_0_30_Trouble_Fun
    {
        public class OuterClass
        {
            public IDemo MyDemo { get; set; }
            public void SetType<T>(InnerClass<T> t)
            {
                MyDemo = t;
            }
        }

        [NotifyPropertyChanged] //COMMENTING THIS LINE OUT MAKES THE CODE WORK
        public class InnerClass<T> : IDemo
        {
            public InnerClass(List<T> records)
            {
                Records = records;
                RecordType = typeof(T);
            }

            //public long SelectedId { get; set; } //THESE
            //public long GetMaxId() // WORK
            public long? SelectedId { get; set; }
            public long? GetMaxId()
            {
               var maxid = (from dynamic r in Records
                   select RecordType?.GetProperty(ValueMember)?.GetValue(r, null)).Max();
                   return maxid ?? -1;

                /* REPLACING THE THREE LINES ABOVE WITH THE TWO LINES BELOW MAKES THE CODE WORK */
                //return (from dynamic r in Records
                //select RecordType?.GetProperty(ValueMember)?.GetValue(r, null)).Max();
            }

            public List<T> Records { get; set; }
            public string ValueMember { get; }
            public Type RecordType { get; }
            
        }

        public interface IDemo
        {
            string ValueMember { get; }
            Type RecordType { get; }

            /* REMOVING THE Nullable (?) operator from the two lines above a
             * as well as from the corresponding lines in the implementing class
             * makes the code work */

            long? SelectedId { get; set; }
            long? GetMaxId();

            //long SelectedId { get; set; } // THESE
            //long GetMaxId(); // WORK
        }
    }

  3. 3 Posted by henry.nordstrom on 31 Jul, 2017 04:19 PM

    henry.nordstrom's Avatar

    ...so it seems that a combination of dynamic values, nullable values, interfaces and generics together with the [INotifyPropertyChanged] aspect is a recipe for disaster.

  4. Support Staff 4 Posted by PostSharp Techn... on 01 Aug, 2017 09:57 AM

    PostSharp Technologies's Avatar

    Hello,

    Thank you for reporting the issue and providing a reproduction. This has already been filed earlier in our bug tracker (#15294) and the work on a bug fix is in progress. We'll get back to you once the fix is released.

    -alex

  5. Support Staff 5 Posted by PostSharp Techn... on 05 Sep, 2017 02:59 PM

    PostSharp Technologies's Avatar

    Hello,

    The bug #15294 has been fixed in the PostSharp build 5.0.32.
    Should you need further help with this issue, don't hesitate to re-open this discussion.

    -alex

  6. PostSharp Technologies closed this discussion on 05 Sep, 2017 02:59 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac