1

For some reason, TDS has started creating duplicate properties for one of my "constants" partial classes as well as the associated interface in my TdsCodeGen.cs. It's only doing it for one component. It's not doing it for all of the fields of the component.

Example:

public static partial class IComponentConstants{

        public const string TemplateIdString = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
        public static readonly ID TemplateId = new ID(TemplateIdString);
        public const string TemplateName = "Component";

        //HERE'S THE FIRST SET OF PROPERTIES FOR THE "INTROTEXT" FIELD
        public static readonly ID IntroTextFieldId = new ID("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
        public const string IntroTextFieldName = "Intro Text";

        public static readonly ID QuestionHeaderTextFieldId = new ID("11111111-1111-1111-1111-111111111111");
        public const string QuestionHeaderTextFieldName = "Question Header Text";

        public static readonly ID ResultsFooterTextFieldId = new ID("22222222-2222-2222-2222-22222222222");
        public const string ResultsFooterTextFieldName = "Results Footer Text";

        //HERE'S THE SECOND SET OF PROPERTIES FOR THE "INTROTEXT" FIELD
        public static readonly ID IntroTextFieldId = new ID("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
        public const string IntroTextFieldName = "Intro Text";
}

Notice that the ID is identical for both. I checked the master database and there is only one field by that name for that component or, for that matter, any component.

The same/similar thing happens with the partial interface (summary comments added by TDS have been removed for readability):

public partial interface IComponentTool : IGlassBase {

            [SitecoreField(IComponentConstants.IntroTextFieldName)]
                string IntroText  {get; set;}

            [SitecoreField(IComponentConstants.QuestionHeaderTextFieldName)]
                string QuestionHeaderText  {get; set;}

            [SitecoreField(IComponentConstants.ResultsFooterTextFieldName)]
                string ResultsFooterText  {get; set;}

            //Visual Studio gives the message 
            //"Ambiguity between 'IComponentConstants.IntroTextFieldName'                                                               
            //and 'IComponentConstants.IntroTextFieldName'
            //here ----------------------------[                ]
            [SitecoreField(IComponentConstants.IntroTextFieldName)]
                string IntroText  {get; set;}
            //here ----[       ] Visual Studio says
            //The type 'IComponent' already contains
            //a definition for 'IntroText'
}

This happens with most, but not all of the properties.

4
  • Have you tried recreating the template to see if the problem recurs? – Dan Sinclair Feb 14 '19 at 0:44
  • Yes, I did and that resolved it. Would have rather have found another way to fix it though. I re-imported the template from our production server and the errors came back, so it would seem my recent copying of fields was probably not the cause of the errors, but they were around for a while without me noticing. – Michael Feb 14 '19 at 15:04
  • I'm not sure exactly how to do this (I've never tried), but you may be able to add some logging to your .tt file to gather some more information about why it's hitting the same fields multiple times. – Dan Sinclair Feb 14 '19 at 15:05
  • That's a good idea, thank you. For now, I'm going with the recreation and I'll look into logging as I have time (ha ha...). – Michael Feb 14 '19 at 15:45
1

This can happen if the same template is included as a base template multiple times on another template. Usually this happens if you have the same template included as a base template in multiple templates that are also used as base templates to compose your template.

That's hard to digest; an example would be more helpful, I think:

  • Template: Vehicle
    • Field: Door Count
    • Field: Window Count
    • Base Templates: none
  • Template: Car
    • Field: Trunk Volume
    • Base Templates: Vehicle
  • Template: Truck
    • Field: Rear Bed Volume
    • Base Templates: Vehicle
  • Template: SUV
    • Base Templates: Car, Truck

In the above example, the SUV template could have the fields from the Vehicle base template duplicated in the .tt outputs.

3
  • The only base template for this component's template is the "Standard Template". There shouldn't be any templates using this as a base, but I'm not sure how to confirm that. – Michael Feb 13 '19 at 21:53
  • So all the fields in question are defined on the one template (Component Tool)? – Dan Sinclair Feb 13 '19 at 21:53
  • Yes. Now I just added an edit to my question about what may be a related causal incident, but I'm doubtful about it. I tried coping some fields, which are not being duplicated, from another template. I did not add that template as a base template because there are other fields that I don't want. – Michael Feb 13 '19 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.