modelsbuilder / ModelsBuilder.Original

The Community Models Builder for Umbraco
MIT License
114 stars 49 forks source link

Add global:: to generated models #92

Closed kipusoep closed 8 years ago

kipusoep commented 8 years ago

First of all; thanks for creating this nice tool, it's great :-)

I ran into an issue with the default umbracoFile property inside the generated Image class:

///<summary>
/// Upload image
///</summary>
[ImplementPropertyType("umbracoFile")]
public Umbraco.Web.Models.ImageCropDataSet UmbracoFile
{
    get { return this.GetPropertyValue<Umbraco.Web.Models.ImageCropDataSet>("umbracoFile"); }
}

We have used the namespace 'Infocaster.Umbraco' a lot and so the compiler thinks Umbraco.Something means Infocaster.Umbraco.Something. To fix this we need global::Umbraco.Something. Could you add this to the generated models?

zpqrtbnk commented 8 years ago

Mmm... weird: we do have some code that manages "ambiguous symbols" and is supposed to prepend global:: to types that would otherwise be ambiguous. Can you give me the entire list of 'using' clauses that come at top of the generated file?

kipusoep commented 8 years ago
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
using Umbraco.ModelsBuilder;
using Umbraco.ModelsBuilder.Umbraco;
zpqrtbnk commented 8 years ago

Wondering why the compiler would think Umbraco.Something is Infocaster.Umbraco.Something if there is no using clause for Infocaster - how would the compiler know about it? (or am I missing something obvious)?

kipusoep commented 8 years ago

I think because I'm inside the namespace 'InfoCaster.Something' ;-)

zpqrtbnk commented 8 years ago

Aha - probably overlooked that one. So your models' namespace would be eg Infocaster.Models, right? OK, looking into it.

kipusoep commented 8 years ago

Exactly :-) Great!

zpqrtbnk commented 8 years ago

Reproduced, fixed in 3.0.1.

kipusoep commented 8 years ago

Thanks, nice work! :+1: