Skip to content

Commit

Permalink
update to v 0.7.0.0 - bug fix with unidirectional self referential en…
Browse files Browse the repository at this point in the history
…tities + upgrade to latest nuget packages.
  • Loading branch information
jtraband committed Nov 29, 2018
1 parent cd20335 commit 5abc663
Show file tree
Hide file tree
Showing 21 changed files with 3,026 additions and 105 deletions.
45 changes: 8 additions & 37 deletions Breeze.Sharp/Breeze.Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,40 +118,8 @@
<Compile Include="Validators.cs" />
<Compile Include="Validator.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Data.Edm">
<HintPath>..\packages\Microsoft.Data.Edm.5.6.3\lib\portable-net45+wp8+win8+wpa\Microsoft.Data.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.OData">
<HintPath>..\packages\Microsoft.Data.OData.5.6.3\lib\portable-net45+wp8+win8+wpa\Microsoft.Data.OData.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Services.Client">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.6.3\lib\portable-net45+wp8+win8+wpa\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Formatting">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\portable-wp8+netcore45+net45+wp81+wpa81\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Spatial">
<HintPath>..\packages\System.Spatial.5.6.3\lib\portable-net45+wp8+win8+wpa\System.Spatial.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="__RequestedFeatures.txt" />
Expand All @@ -161,13 +129,16 @@
<ItemGroup>
<EmbeddedResource Include="LocalizedMessages.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client">
<Version>5.2.7</Version>
</PackageReference>
<PackageReference Include="Microsoft.Data.Services.Client">
<Version>5.8.4</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
2 changes: 1 addition & 1 deletion Breeze.Sharp/EntityAspect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ private void LinkUnattachedChildren() {
}
} else {
// unidirectional
if (np.ParentType == EntityType) {
if (np.ParentType == EntityType && np.ParentType != np.EntityType) {

parentToChildNp = np;
if (parentToChildNp.IsScalar) {
Expand Down
37 changes: 22 additions & 15 deletions Breeze.Sharp/JNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Breeze.Sharp.Core;
using Newtonsoft.Json.Serialization;
using System.Globalization;
using System.Reflection;

namespace Breeze.Sharp {

Expand Down Expand Up @@ -59,7 +60,7 @@ public Object ToObject(Type t, bool shouldCamelCase = false) {
public override String ToString() {
return _jo.ToString();
}

public Object Config {
get;
set;
Expand All @@ -78,11 +79,11 @@ public void AddPrimitive(String propName, Object value, Object defaultValue = nu
AddRaw(propName, new JValue(value));
}

public void AddEnum<TEnum>(String propName, TEnum value) where TEnum: struct {
public void AddEnum<TEnum>(String propName, TEnum value) where TEnum : struct {
AddRaw(propName, new JValue(value.ToString()));
}

public void AddEnum<TEnum>(String propName, TEnum? value) where TEnum: struct {
public void AddEnum<TEnum>(String propName, TEnum? value) where TEnum : struct {
if (value == null) return;
AddRaw(propName, new JValue(value.ToString()));
}
Expand Down Expand Up @@ -110,7 +111,7 @@ public void AddMap<T>(String propName, IDictionary<String, T> map) {
if (!map.Values.Any()) return;

var jn = BuildMapNode<T>(map);

AddRaw(propName, jn._jo);
}

Expand All @@ -133,7 +134,14 @@ private void AddRaw(String propName, JToken jt) {
public Object Get(String propName, Type objectType) {
var prop = _jo.Property(propName);
if (prop == null) return null;
var val = prop.Value.ToObject(objectType);
var nonnullableType = objectType.GenericTypeArguments.FirstOrDefault();
// TODO: Ugh.. hack to allow latest NewtonSoft Json to work correctly with nullable enums.
Object val;
if (nonnullableType != null && nonnullableType.GetTypeInfo().IsEnum) {
val = Enum.Parse(nonnullableType, prop.Value.ToString());
} else {
val = prop.Value.ToObject(objectType);
}
return val;
}

Expand All @@ -144,7 +152,7 @@ public Object Get(String propName, Type objectType) {
return val;
}

public T GetToken<T>(String propName ) where T: JToken {
public T GetToken<T>(String propName) where T : JToken {
var prop = _jo.Property(propName);
if (prop == null) return null;
return (T)prop.Value;
Expand All @@ -160,7 +168,7 @@ public T GetToken<T>(String propName ) where T: JToken {
}
}

public TEnum? GetNullableEnum<TEnum>(String propName) where TEnum: struct {
public TEnum? GetNullableEnum<TEnum>(String propName) where TEnum : struct {
var val = Get<String>(propName);
if (val == null) {
return null;
Expand All @@ -170,7 +178,7 @@ public T GetToken<T>(String propName ) where T: JToken {
}

// for non newable types like String, Int etc..
public IEnumerable<T> GetArray<T>(String propName) {
public IEnumerable<T> GetArray<T>(String propName) {
var items = GetToken<JArray>(propName);
if (items == null) {
return Enumerable.Empty<T>();
Expand All @@ -185,8 +193,7 @@ public IEnumerable<T> GetArray<T>(params String[] propNames) {
var items = propNames.Select(pn => GetToken<JArray>(pn)).FirstOrDefault(jt => jt != null);
if (items == null) {
return Enumerable.Empty<T>();
}
else {
} else {
return items.Select(item => {
return item.ToObject<T>();
});
Expand All @@ -206,7 +213,7 @@ public IEnumerable<Object> GetArray(String propName, IEnumerable<Type> toTypes)

public Dictionary<String, T> GetMap<T>(String propName) {
var map = (JObject)GetToken<JObject>(propName);

var rmap = new Dictionary<String, T>();
if (map == null) return rmap;
foreach (var kvp in map) {
Expand All @@ -226,7 +233,7 @@ public Dictionary<String, Object> GetMap(String propName, Func<String, Type> toT
return rmap;
}

public JNode GetJNode(String propName) {
public JNode GetJNode(String propName) {
var item = (JObject)GetToken<JObject>(propName);
if (item == null) return null;
var jNode = new JNode(item);
Expand All @@ -252,7 +259,7 @@ public IEnumerable<JNode> GetJNodeArray(String propName) {
public IDictionary<String, JNode> GetJNodeMap(String propName) {
var map = GetToken<JObject>(propName);
if (map == null) return null;
var rmap = ((IDictionary<String, JToken>) map).ToDictionary(kvp => kvp.Key, kvp => new JNode((JObject) kvp.Value));
var rmap = ((IDictionary<String, JToken>)map).ToDictionary(kvp => kvp.Key, kvp => new JNode((JObject)kvp.Value));
return rmap;
}

Expand All @@ -267,7 +274,7 @@ public IDictionary<String, IEnumerable<JNode>> GetJNodeArrayMap(String propName)
}
return rmap;
}



// pass in a simple value, a JNode or a IJsonSerializable and returns either a simple value or a JObject or a JArray
Expand Down Expand Up @@ -317,7 +324,7 @@ public TextWriter SerializeTo(TextWriter textWriter) {
#else
serializer.Formatting = Formatting.None;
#endif

using (var jtw = new JsonTextWriter(textWriter)) {
serializer.Serialize(jtw, _jo);
jtw.Flush();
Expand Down
4 changes: 2 additions & 2 deletions Breeze.Sharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("0.6.1.0")]
[assembly: AssemblyFileVersion("0.6.1.0")]
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C291ECD4-FD4E-43C2-A6BE-BAB5B7BA8E6E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Breeze.Sharp.Tests</RootNamespace>
<AssemblyName>Breeze.Sharp.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NOT_NHIBERNATE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Data.Edm, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.3\lib\net40\Microsoft.Data.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.OData.5.6.3\lib\net40\Microsoft.Data.OData.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.6.3\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Spatial, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Spatial.5.6.3\lib\net40\System.Spatial.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="MetadataTests.cs" />
<Compile Include="PartialMetadataTests.cs" />
<Compile Include="PredicateQueryTests.cs" />
<Compile Include="StandaloneTests.cs" />
<Compile Include="EdmundsTests.cs" />
<Compile Include="MetadataByHandTests.cs" />
<Compile Include="InheritanceBillingTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="InheritanceProduceTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ValidationTests.cs" />
<Compile Include="EntityManagerTests.cs" />
<Compile Include="LocalQueryTests.cs" />
<Compile Include="SaveTests.cs" />
<Compile Include="NamedQueryTests.cs" />
<Compile Include="IEditableObjectTests.cs" />
<Compile Include="AttachTests.cs" />
<Compile Include="ExportImportTests.cs" />
<Compile Include="ComplexTypeTests.cs" />
<Compile Include="QueryTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFns.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Breeze.Sharp\Breeze.Sharp.csproj">
<Project>{54b1ce10-2847-4565-839a-26da3a51af38}</Project>
<Name>Breeze.Sharp</Name>
</ProjectReference>
<ProjectReference Include="..\Model.CodeCamper\Model.CodeCamper.csproj">
<Project>{3115a147-39a3-4e8f-a8ba-265bb2571acc}</Project>
<Name>Model.CodeCamper</Name>
</ProjectReference>
<ProjectReference Include="..\Model.Edmunds\Model.Edmunds.csproj">
<Project>{c365d56f-1bd4-4d6c-88ef-84f78de9243d}</Project>
<Name>Model.Edmunds</Name>
</ProjectReference>
<ProjectReference Include="..\Model.Inheritance.Billing.Sharp\Model.Inheritance.Billing.Sharp.csproj">
<Project>{58b41cc6-8d34-40c4-9342-db55ae6cca02}</Project>
<Name>Model.Inheritance.Billing.Sharp</Name>
</ProjectReference>
<ProjectReference Include="..\Model.Inheritance.Produce.Sharp\Model.Inheritance.Produce.Sharp.csproj">
<Project>{73c7f5c5-53ee-4f8c-af80-2fd74a9cf553}</Project>
<Name>Model.Inheritance.Produce.Sharp</Name>
</ProjectReference>
<ProjectReference Include="..\Model.Northwind.Sharp\Model.Northwind.Sharp.csproj">
<Project>{e357f17b-6a21-4682-b7c8-3ebfebf862f3}</Project>
<Name>Model.Northwind.Sharp</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit 5abc663

Please sign in to comment.