Bug Report T528883
Visible to All Users

Templates - Smart Constructor - Adding a default value to an optional parameter should not change a linked value

created 8 years ago

Hi

Consider the following class;

C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace VtlFishTracker { class VtlInvoicePayment { public int InvoiceId { get; set; } public int CustomerId { get; set; } public DateTime InvoicePaymentDate { get; set; } public decimal AmountPaid { get; set; } public int PaymentTypeId { get; set; } public string ChequeNumber { get; set; } public DateTime? ChequeDate { get; set; } public int? BankAccountId { get; set; } public int? InvoiceCreditNoteId { get; set; } public decimal? ConversionFactor { get; set; } public bool? MultipleInvoicesPaid { get; set; } public bool? PaidIntoBank { get; set; } public VtlInvoicePayment() { } } }

if after I have entered the properties I type cc and then space and ensure that none of the parameters are selected in the smart constructor I end up with the standard constructor as seen.

Now suppose that I want an overloaded constructor with some of the properties as optional parameters in the constructor.  When I type cc and select all in the smart constructor it creates all of the parameters but when I then try to assign a value it acts as if I am renaming the parameter (which is not what I want), see the attached movie.

Am I doing something wrong here, or is it not possible to use the smart constructor if one wants optional parameters in a constructor?

Many thanks

Dom

Show previous comments (4)
DevExpress Support Team 8 years ago

    Hi Dom,

    The fixed version does not change the linked value in the constructor body when you define a default value for a parameter.

    Would you please describe in detail what you mean by "allow for the creation of optional parameters" ?

      Hi Pavel

      I guess the problem is that prolonged use of CodeRush makes one lazy!!

      If you look at the original class code above you'll see that the last few properties are nullable types.  In essence I'm hoping that it would be possible for code rush to automatically assign null values to those in the constructor's signature, thus making them optional.

      Pure laziness on my part I know…but isn't that what CodeRush is for?

      Dom

      DevExpress Support Team 8 years ago

        Thank you for the clarification, Dom!

        We believe that we can add an option for Smart Constructor to generate optional parameters where it make sense.

        I have added this request to our product backlog, so we will consider it when we plan future releases.

        Answers approved by DevExpress Support

        created 8 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.