Skip to content

Commit

Permalink
both normal and god assembly OK
Browse files Browse the repository at this point in the history
  • Loading branch information
zijianhuang committed Jun 7, 2024
1 parent 33748cb commit 3b9c481
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 268 deletions.
260 changes: 0 additions & 260 deletions DemoCoreWeb.ClientApiTextJson/WebApiClientTextJsonAuto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8635,16 +8635,6 @@ namespace DemoWebApi.DemoData.Another.Client
{


[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public struct MyPoint
{

public double X;

public double Y;
}

/// <summary>
/// 2D position
/// with X and Y
Expand All @@ -8670,46 +8660,6 @@ namespace DemoWebApi.DemoData.Base.Client
{


[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class Entity : object
{

[System.Runtime.Serialization.DataMember()]
public System.Collections.Generic.IList<DemoWebApi.DemoData.Client.Address> Addresses { get; set; }

/// <summary>
/// Max length: 255
/// </summary>
[System.ComponentModel.DataAnnotations.MaxLength(255)]
[System.Runtime.Serialization.DataMember()]
public string EmailAddress { get; set; }

[System.Runtime.Serialization.DataMember()]
public System.Nullable<System.Guid> Id { get; set; }

/// <summary>
/// Required
/// Min length: 2
/// Max length: 255
/// </summary>
[System.ComponentModel.DataAnnotations.RequiredAttribute()]
[System.ComponentModel.DataAnnotations.MinLength(2)]
[System.ComponentModel.DataAnnotations.MaxLength(255)]
[System.Runtime.Serialization.DataMember(IsRequired =true)]
public string Name { get; set; }

[System.Runtime.Serialization.DataMember()]
public System.Collections.ObjectModel.ObservableCollection<DemoWebApi.DemoData.Client.PhoneNumber> PhoneNumbers { get; set; }

/// <summary>
/// Matching regular expression pattern: https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)
/// </summary>
[System.ComponentModel.DataAnnotations.RegularExpressionAttribute(@"https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)")]
[System.Runtime.Serialization.DataMember()]
public System.Uri Web { get; set; }
}

/// <summary>
/// Base class of company and person
/// </summary>
Expand Down Expand Up @@ -8761,111 +8711,6 @@ namespace DemoWebApi.DemoData.Client
{


[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class Address : object
{

/// <summary>
/// String length: inclusive between 2 and 50
/// </summary>
[System.ComponentModel.DataAnnotations.StringLength(50, MinimumLength=2)]
[System.Runtime.Serialization.DataMember()]
public string City { get; set; }

/// <summary>
/// String length: inclusive between 2 and 30
/// </summary>
[System.ComponentModel.DefaultValueAttribute("Australia")]
[System.ComponentModel.DataAnnotations.StringLength(30, MinimumLength=2)]
[System.Runtime.Serialization.DataMember()]
public string Country { get; set; } = "Australia";

[System.Runtime.Serialization.DataMember()]
public System.Guid Id { get; set; }

/// <summary>
/// String length: inclusive between 2 and 10
/// </summary>
[System.ComponentModel.DataAnnotations.StringLength(10, MinimumLength=2)]
[System.Runtime.Serialization.DataMember()]
public string PostalCode { get; set; }

/// <summary>
/// String length: inclusive between 2 and 30
/// </summary>
[System.ComponentModel.DataAnnotations.StringLength(30, MinimumLength=2)]
[System.Runtime.Serialization.DataMember()]
public string State { get; set; }

/// <summary>
/// String length: inclusive between 2 and 100
/// </summary>
[System.ComponentModel.DataAnnotations.StringLength(100, MinimumLength=2)]
[System.Runtime.Serialization.DataMember()]
public string Street1 { get; set; }

/// <summary>
/// String length: inclusive between 2 and 100
/// </summary>
[System.ComponentModel.DataAnnotations.StringLength(100, MinimumLength=2)]
[System.Runtime.Serialization.DataMember()]
public string Street2 { get; set; }

[System.ComponentModel.DefaultValueAttribute(AddressType.Residential)]
[System.Runtime.Serialization.DataMember()]
public DemoWebApi.DemoData.Client.AddressType Type { get; set; } = AddressType.Residential;

[System.Runtime.Serialization.DataMember()]
public DemoWebApi.DemoData.Another.Client.MyPoint Location { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PhoneNumber : object
{

/// <summary>
/// Max length: 120
/// </summary>
[System.ComponentModel.DataAnnotations.MaxLength(120)]
[System.Runtime.Serialization.DataMember()]
public string FullNumber { get; set; }

[System.Runtime.Serialization.DataMember()]
public DemoWebApi.DemoData.Client.PhoneType PhoneType { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public enum PhoneType
{

[System.Runtime.Serialization.EnumMember()]
Tel,

[System.Runtime.Serialization.EnumMember()]
Mobile,

[System.Runtime.Serialization.EnumMember()]
Skype,

[System.Runtime.Serialization.EnumMember()]
Fax,
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public enum AddressType
{

[System.Runtime.Serialization.EnumMember()]
Postal,

[System.Runtime.Serialization.EnumMember()]
Residential,
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class Address : object
Expand Down Expand Up @@ -9156,36 +9001,6 @@ public class MimsPackage : object
public string Tag { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public enum MyEnumType
{

[System.Runtime.Serialization.EnumMember()]
First = 1,

[System.Runtime.Serialization.EnumMember()]
Two = 2,
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class MimsResult<T> : object
{

[System.Runtime.Serialization.DataMember()]
public System.DateTime GeneratedAt { get; set; }

[System.Runtime.Serialization.DataMember()]
public string Message { get; set; }

[System.Runtime.Serialization.DataMember()]
public T Result { get; set; }

[System.Runtime.Serialization.DataMember()]
public bool Success { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class MimsResult<T> : object
Expand Down Expand Up @@ -9510,21 +9325,6 @@ public class Album : object
public string Title { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public enum BodyType
{

[System.Runtime.Serialization.EnumMember()]
Text,

[System.Runtime.Serialization.EnumMember()]
HTML,

[System.Runtime.Serialization.EnumMember()]
MD,
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class Annotation : object
Expand Down Expand Up @@ -9884,54 +9684,6 @@ public class PoemAnnotationMap : object
public System.Guid PoemId { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PoemPictureMap : object
{

[System.Runtime.Serialization.DataMember()]
public System.Guid PictureId { get; set; }

[System.Runtime.Serialization.DataMember()]
public System.Guid PoemId { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PoemTagMap : object
{

[System.Runtime.Serialization.DataMember()]
public System.Guid PoemId { get; set; }

[System.Runtime.Serialization.DataMember()]
public System.Guid TagId { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PoemAlbumMap : object
{

[System.Runtime.Serialization.DataMember()]
public System.Guid AlbumId { get; set; }

[System.Runtime.Serialization.DataMember()]
public System.Guid PoemId { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PoemAnnotationMap : object
{

[System.Runtime.Serialization.DataMember()]
public System.Guid AnnotationId { get; set; }

[System.Runtime.Serialization.DataMember()]
public System.Guid PoemId { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PoemBrief : object
Expand Down Expand Up @@ -10007,18 +9759,6 @@ public class PoemCollection : object
public Fonlow.PoemsApp.Data.Client.Tag[] Tags { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class Tag : object
{

[System.Runtime.Serialization.DataMember()]
public System.Guid Id { get; set; }

[System.Runtime.Serialization.DataMember()]
public string Name { get; set; }
}

[System.Runtime.Serialization.DataContract(Namespace="http://fonlowdemo.com/2020/09")]
[System.SerializableAttribute()]
public class PoemPictureMap : object
Expand Down
1 change: 0 additions & 1 deletion WebApiClientGenCore.Abstract/CodeGenParameters.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Fonlow.Poco2Client;
using System.Linq;
using System.Runtime.CompilerServices;

namespace Fonlow.CodeDom.Web
{
Expand Down
4 changes: 2 additions & 2 deletions WebApiClientGenCore.Abstract/Poco2CsGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public CodeTypeDeclaration CheckOrAdd(Type type, bool dcOnly)
if (type.IsGenericType)
{
var assemblyFilename = type.Assembly.GetName().Name;
if (codeGenSettings.ApiSelections.DataModelAssemblyNames != null && codeGenSettings.ApiSelections.DataModelAssemblyNames.Contains(assemblyFilename)) //to ensure the generic type is custom made, not from BCL or 3rd party you don't want.
if (codeGenSettings.ApiSelections.CherryPickingMethods == CherryPickingMethods.GodAssembly && codeGenSettings.ApiSelections.DataModelAssemblyNames != null && codeGenSettings.ApiSelections.DataModelAssemblyNames.Contains(assemblyFilename)) //to ensure the generic type is custom made, not from BCL or 3rd party you don't want.
{
Type foundTypeDef = PodGenHelper.FindGenericTypeDef(type.Assembly, $"{type.Namespace}.{type.Name}");
if (foundTypeDef is not null && LookupExistingClassOfCs(foundTypeDef) is null)
Expand All @@ -211,7 +211,7 @@ public CodeTypeDeclaration CheckOrAdd(Type type, bool dcOnly)
else
{
var assemblyFilename = type.Assembly.GetName().Name;
if (codeGenSettings.ApiSelections.DataModelAssemblyNames != null && codeGenSettings.ApiSelections.DataModelAssemblyNames.Contains(assemblyFilename))
if (codeGenSettings.ApiSelections.CherryPickingMethods == CherryPickingMethods.GodAssembly && codeGenSettings.ApiSelections.DataModelAssemblyNames != null && codeGenSettings.ApiSelections.DataModelAssemblyNames.Contains(assemblyFilename))
{
AddCodeTypeDeclaration(type, dcOnly);
}
Expand Down
11 changes: 6 additions & 5 deletions WebApiClientGenCore/ControllersClientApiGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ void GenerateCsFromPocoAssemblies()
if (codeGenSettings.ApiSelections.DataModelAssemblyNames != null)
{
Assembly[] allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly[] assemblies = allAssemblies.Where(d => codeGenSettings.ApiSelections.DataModelAssemblyNames.Any(k => k.Equals(d.GetName().Name, StringComparison.OrdinalIgnoreCase)))
.OrderBy(n => n.FullName)
.ToArray();
CherryPickingMethods cherryPickingMethods = codeGenSettings.ApiSelections.CherryPickingMethods.HasValue ? (CherryPickingMethods)codeGenSettings.ApiSelections.CherryPickingMethods.Value : CherryPickingMethods.DataContract;
foreach (Assembly assembly in assemblies)
foreach (string assemblyName in codeGenSettings.ApiSelections.DataModelAssemblyNames)
{
Poco2CsGenerator.CreateCodeDomForAssembly(assembly, cherryPickingMethods, null);
Assembly assembly = allAssemblies.FirstOrDefault(d => d.GetName().Name.Equals(assemblyName, StringComparison.OrdinalIgnoreCase));
if (assembly != null)
{
Poco2CsGenerator.CreateCodeDomForAssembly(assembly, cherryPickingMethods, codeGenSettings.ClientApiOutputs.DataAnnotationsToComments);
}
}
}

Expand Down

0 comments on commit 3b9c481

Please sign in to comment.