Skip to content

Commit d804b1e

Browse files
committed
DateOnly
1 parent e5068b0 commit d804b1e

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

WebApiClientGenCore.Abstract/ControllersTsClientApiGenBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public abstract class ControllersTsClientApiGenBase
2323
protected CodeCompileUnit TargetUnit { get; private set; }
2424

2525
readonly CodeGenConfig apiSelections;
26-
protected JSOutput jsOutput;
26+
protected readonly JSOutput jsOutput;
2727
readonly ClientApiTsFunctionGenAbstract apiFunctionGen; //to be injected in ctor of derived class.
2828
readonly IDocCommentTranslate poco2CsGen;
2929

WebApiClientGenCore.NG2FormGroup/CodeObjectHelperForNg2FormGroup.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ string GetCodeMemberFieldTextForAngularFormGroup(CodeMemberField codeMemberField
230230
{
231231
Attribute[] customAttributes = codeMemberField.UserData[UserDataKeys.CustomAttributes] as Attribute[];
232232
string fieldName = codeMemberField.Name.EndsWith('?') ? codeMemberField.Name.Substring(0, codeMemberField.Name.Length - 1) : codeMemberField.Name;
233+
string tsTypeName = RefineAngularFormControlTypeName(codeMemberField);
234+
bool isFieldDateOnly = false;
233235
FieldTypeInfo fieldTypeInfo = codeMemberField.Type.UserData[UserDataKeys.FieldTypeInfo] as FieldTypeInfo;
236+
if (fieldTypeInfo?.ClrType == typeof(DateOnly) || fieldTypeInfo?.ClrType == typeof(DateOnly?))
237+
{
238+
isFieldDateOnly = true;
239+
}
234240

235241
if (customAttributes?.Length > 0)
236242
{
@@ -312,8 +318,6 @@ string GetCodeMemberFieldTextForAngularFormGroup(CodeMemberField codeMemberField
312318
}
313319
}
314320

315-
bool isFieldDateOnly = false;
316-
317321
if (fieldTypeInfo != null)
318322
{
319323
bool validatorsHasValidatorMinOrMax = validatorList.Exists(d => d.Contains("max(") || d.Contains("min"));
@@ -329,15 +333,9 @@ string GetCodeMemberFieldTextForAngularFormGroup(CodeMemberField codeMemberField
329333
{
330334
validatorList.Add(integralJsStringValidators);
331335
}
332-
333-
if (fieldTypeInfo.ClrType == typeof(DateOnly) || fieldTypeInfo.ClrType == typeof(DateOnly?))
334-
{
335-
isFieldDateOnly = true;
336-
}
337336
}
338337

339338
string text = String.Join(", ", validatorList);
340-
string tsTypeName = RefineAngularFormControlTypeName(codeMemberField);
341339

342340
if (isFieldDateOnly && careForDateOnly)
343341
{
@@ -351,8 +349,14 @@ string GetCodeMemberFieldTextForAngularFormGroup(CodeMemberField codeMemberField
351349
}
352350
else
353351
{
354-
string tsTypeName = RefineAngularFormControlTypeName(codeMemberField);
355-
return $"{fieldName}: new FormControl<{tsTypeName}>(undefined)";
352+
if (isFieldDateOnly && careForDateOnly)
353+
{
354+
return $"{fieldName}: CreateDateOnlyFormControl()";
355+
}
356+
else
357+
{
358+
return $"{fieldName}: new FormControl<{tsTypeName}>(undefined)";
359+
}
356360
}
357361
}
358362

WebApiClientGenCore.NG2FormGroup/WebApiClientGenCore.NG2FormGroup.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1414
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1515
<AssemblyName>Fonlow.WebApiClientGenCore.NG2FormGroup</AssemblyName>
16-
<Version>1.9.2</Version>
16+
<Version>1.9.3</Version>
1717
<PackageTags>Angular</PackageTags>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>
1919
<RepositoryUrl>https://github.com/zijianhuang/webapiclientgen</RepositoryUrl>

WebApiClientGenCore/ClientApiFunctionGen.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ CodeMemberMethod CreateApiFunction()
117117
AddCustomPocoTypeForCs(returnType);
118118
//create method
119119
clientMethod = forAsync ? CreateMethodBasicForAsync() : CreateMethodBasic();
120-
//#if DEBUG
121-
// if (methodName == "GetHeroes")
122-
// {
123-
// Console.WriteLine("GetHeroes");
124-
// }
125-
//#endif
120+
126121
CreateDocComments();
127122
if (codeGenOutputsSettings.MaybeNullAttributeOnMethod && returnTypeDecoratedWithMaybeNullable)
128123
{

0 commit comments

Comments
 (0)