Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

B5 NT-generated code fails when enums are exposed as parameters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    B5 NT-generated code fails when enums are exposed as parameters

    Please see the attached file to reproduce. This compiled in previous beta builds, as well as NT7.
    Attached Files

    #2
    Hello,

    You should be able to resolve this by removing the enum declaration from the Indicators namespace and re-locating it outside of the namespace entirely. I've attached an updated copy of your script which should work for you.
    Attached Files
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Ok, though the same issue is present when the enum is scoped even publically as an indicator class member. This is valid code and will compile, if not for the NT generated code. Worked in previous builds of 8 and in 7 too. If you scope enums outside the indicator namespace you create a global name collision potential across the other namespaces. If developers A and B try to use the same enum name there will be chaos for customers at install time. Let me know if I'm missing something here...

      Comment


        #4
        I can definitely see your concern. Just to be sure this is not a new bug, I've just retested your original code on Beta 4 and Beta 3, but I'm seeing the same scope error that I saw on Beta 5. Can you think of anything else that was different in your implementation of this code in B4 or B3 (or earlier)?
        Dave I.NinjaTrader Product Management

        Comment


          #5
          In code I wrote in B3-B4 I have enums scoped as public class members then exposed as parameters, which compiled and worked fine at run time. I looked in my source control change logs and in previous builds the NT generated code wasn't including the enums in the constructors. In B5 it does include them and won't compile. So it would seem to be this is a new issue in B5.

          If I take one of the previous versions from source control with the enums and the old footer code and compile in B5 it works. But once I touch anything in the properties section of the code NT regenerates the footer code and breaks the build.

          Hope this helps (and helps get this fixed in B6 ;-} )...

          Comment


            #6
            Originally posted by RanchoDinero View Post
            In code I wrote in B3-B4 I have enums scoped as public class members then exposed as parameters, which compiled and worked fine at run time. I looked in my source control change logs and in previous builds the NT generated code wasn't including the enums in the constructors. In B5 it does include them and won't compile. So it would seem to be this is a new issue in B5.

            If I take one of the previous versions from source control with the enums and the old footer code and compile in B5 it works. But once I touch anything in the properties section of the code NT regenerates the footer code and breaks the build.

            Hope this helps (and helps get this fixed in B6 ;-} )...
            Look again. If the Ninjatrader generated code does not include the parameter in the constructor, you probably did not decorate the property with the [NinjaScriptProperty] attribute.

            Comment


              #7
              Thanks but nope. Not the case. The issue is what I described. The same code which is decorated correctly compiles and runs in earlier builds, not in b5.

              Comment


                #8
                I've got an update (and good news) on this one. You should be able to declare and define your enum within the Indicators namespace, but the key is that you will need to use a fully qualified name when declaring your properties:

                Code:
                public NinjaTrader.NinjaScript.Indicators.FooEnum Bar { get; set; }
                Dave I.NinjaTrader Product Management

                Comment


                  #9
                  Dave -

                  This'll work just fine. Thanks for the digging, appreciated.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by owenwong, Today, 06:34 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post owenwong  
                  Started by REI140205, Today, 06:17 PM
                  0 responses
                  12 views
                  0 likes
                  Last Post REI140205  
                  Started by Gathem, Today, 06:06 PM
                  1 response
                  13 views
                  0 likes
                  Last Post Gathem
                  by Gathem
                   
                  Started by tg1886, Today, 04:09 PM
                  3 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_ShawnB  
                  Started by mythue, Today, 03:48 PM
                  2 responses
                  13 views
                  0 likes
                  Last Post mythue
                  by mythue
                   
                  Working...
                  X