Skip to content

Commit

Permalink
Changes per Pull Request review.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycrider committed Feb 19, 2015
1 parent 1365839 commit b385f26
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 19 deletions.
7 changes: 5 additions & 2 deletions src/Core/Vipr.Core/CodeModel/OdcmModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -54,15 +55,17 @@ public void AddType(OdcmType type)
}

_Types.Add(type);
;

odcmNamespace.Types.Add(type);
}

public bool TryResolveType<T>(string name, string @namespace, out T type) where T : OdcmType
{
string canonicalName = OdcmObject.MakeCanonicalName(name, @namespace);

foreach (OdcmType candidate in _Types)
{
if (string.Equals(candidate.Name, name) && string.Equals(candidate.Namespace, @namespace))
if (candidate.CanonicalName().Equals(canonicalName, StringComparison.InvariantCulture))
{
type = candidate as T;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Vipr.Core/CodeModel/OdcmObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public virtual string CanonicalName()

public static string MakeCanonicalName(string name, string @namespace)
{
return string.Format("{0}.{1}", name, @namespace);
return string.Format("{1}.{0}", name, @namespace);
}

public static string MakeCanonicalName(string name, string @namespace, params OdcmType[] parameters)
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Vipr.Core/CodeModel/OdcmType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public string FullName

public override string CanonicalName()
{
return string.Format("{0}.{1}", Namespace, base.CanonicalName());
return MakeCanonicalName(base.CanonicalName(), Namespace);
}
}
}
4 changes: 2 additions & 2 deletions src/Writers/CSharpWriter/Attribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public static Attribute ForLowerCaseProperty()
};
}

public static Attribute ForMicrosoftOdataClientKey(OdcmClass odcmClass)
public static Attribute ForMicrosoftOdataClientKey(OdcmEntityClass odcmClass)
{
return new Attribute
{
Type = new Type(new Identifier("global::Microsoft.OData.Client", "Key")),
Parameters = ((OdcmEntityClass)odcmClass).Key.ToDictionary<OdcmProperty, string, string>(p => p.Name, p => null)
Parameters = odcmClass.Key.ToDictionary<OdcmProperty, string, string>(p => p.Name, p => null)
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Writers/CSharpWriter/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace CSharpWriter
{
public class Attributes
{
public static IEnumerable<Attribute> ForConcrete(OdcmClass odcmClass)
public static IEnumerable<Attribute> ForConcrete(OdcmEntityClass odcmClass)
{
return new[]
{
Expand Down
4 changes: 2 additions & 2 deletions src/Writers/CSharpWriter/Class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static Class ForComplex(OdcmClass odcmClass)
};
}

public static Class ForConcrete(OdcmClass odcmClass)
public static Class ForConcrete(OdcmEntityClass odcmClass)
{
return new Class
{
Expand All @@ -87,7 +87,7 @@ public static Class ForConcrete(OdcmClass odcmClass)
};
}

public static Class ForCollection(OdcmClass odcmClass)
public static Class ForCollection(OdcmEntityClass odcmClass)
{
return new Class
{
Expand Down
4 changes: 2 additions & 2 deletions src/Writers/CSharpWriter/CollectionGetByIdIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class CollectionGetByIdIndexer : Indexer
{
public Dictionary<Parameter, OdcmProperty> ParameterToPropertyMap { get; private set; }

public CollectionGetByIdIndexer(OdcmClass odcmClass)
public CollectionGetByIdIndexer(OdcmEntityClass odcmClass)
{
var keyProperties = ((OdcmEntityClass)odcmClass).Key;
var keyProperties = odcmClass.Key;

ParameterToPropertyMap = keyProperties.ToDictionary(Parameter.FromProperty, p => p);

Expand Down
4 changes: 2 additions & 2 deletions src/Writers/CSharpWriter/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static IEnumerable<Feature> ForOdcmClass(OdcmClass odcmClass)

case OdcmClassKind.MediaEntity:
case OdcmClassKind.Entity:
return Features.ForOdcmClassEntity(odcmClass);
return Features.ForOdcmClassEntity((OdcmEntityClass)odcmClass);

case OdcmClassKind.Service:
return Enumerable.Empty<Feature>();
Expand Down Expand Up @@ -70,7 +70,7 @@ private static IEnumerable<Feature> ForOdcmClassService(OdcmClass odcmClass, Odc
};
}

private static IEnumerable<Feature> ForOdcmClassEntity(OdcmClass odcmClass)
private static IEnumerable<Feature> ForOdcmClassEntity(OdcmEntityClass odcmClass)
{
return new[]
{
Expand Down
2 changes: 1 addition & 1 deletion src/Writers/CSharpWriter/IndexerSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract class IndexerSignature : ParameterizedFunction
public bool IsSettable { get; protected set; }
public bool IsGettable { get; protected set; }

public static IEnumerable<IndexerSignature> ForCollectionInterface(OdcmClass odcmClass)
public static IEnumerable<IndexerSignature> ForCollectionInterface(OdcmEntityClass odcmClass)
{
return new IndexerSignature[]
{
Expand Down
2 changes: 1 addition & 1 deletion src/Writers/CSharpWriter/Indexers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace CSharpWriter
{
public class Indexers
{
public static IEnumerable<Indexer> ForCollection(OdcmClass odcmClass)
public static IEnumerable<Indexer> ForCollection(OdcmEntityClass odcmClass)
{
return new Indexer[]
{
Expand Down
2 changes: 1 addition & 1 deletion src/Writers/CSharpWriter/Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Interface ForFetcher(OdcmClass odcmClass)
};
}

public static Interface ForCollection(OdcmClass odcmClass)
public static Interface ForCollection(OdcmEntityClass odcmClass)
{
return new Interface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void It_exposes_an_AddAsync_method()

private Type[] GetKeyPropertyTypes()
{
return ((OdcmEntityClass)Class).Key
return Class.Key
.Select(p => p.Type)
.Select(t => Proxy.GetClass(t.Namespace, t.Name))
.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void The_Concrete_class_is_attributed_with_MicrosoftOdataClientKey_Attrib

private IEnumerable<string> EntityKeyNames
{
get { return ((OdcmEntityClass)Class).Key.Select(p => p.Name); }
get { return Class.Key.Select(p => p.Name); }
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void The_Base_Concrete_explicitly_implements_a_ToDerived_method()

private IEnumerable<Type> GetKeyTypes()
{
return ((OdcmEntityClass)Class).Key
return Class.Key
.Select(p => p.Type)
.Select(t => Proxy.GetClass(t.Namespace, t.Name));
}
Expand Down

0 comments on commit b385f26

Please sign in to comment.