Skip to content

Commit

Permalink
(cake-buildGH-4150,cake-buildGH-4197) Codegen styling & nullable param
Browse files Browse the repository at this point in the history
* fixes cake-build#4150 - Fix styling warnings
* fixes cake-build#4197 - Fix parameter nullability error
  • Loading branch information
devlead authored and gep13 committed Nov 18, 2023
1 parent eda04f6 commit a9d5d99
Show file tree
Hide file tree
Showing 57 changed files with 197 additions and 393 deletions.
16 changes: 16 additions & 0 deletions src/Cake.Core.Tests/Data/MethodAliasGeneratorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,21 @@ public static dynamic NonGeneric_ExtensionMethodWithDynamicReturnValue(this ICak
{
throw new NotImplementedException();
}

[CakeMethodAlias]
#nullable enable
public static void NonGeneric_ExtensionMethodWithNullableParameter(this ICakeContext context, string? parameter)
#nullable disable
{
throw new NotImplementedException();
}

[CakeMethodAlias]
#nullable enable
public static string? NonGeneric_ExtensionMethodWithNullableReturnValue(this ICakeContext context)
#nullable disable
{
throw new NotImplementedException();
}
}
}
8 changes: 8 additions & 0 deletions src/Cake.Core.Tests/Data/PropertyAliasGeneratorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,13 @@ public static int Cached_Obsolete_ExplicitError_WithMessage(this ICakeContext co
{
throw new NotImplementedException();
}

[CakePropertyAlias(Cache = true)]
#nullable enable
public static string? Cached_Nullable_Type(this ICakeContext context)
#nullable disable
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void Generic_ExtensionMethod<TTest>()
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethod<TTest>(Context);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethod<TTest>(Context);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public TTest Generic_ExtensionMethodWithGenericReturnValue<TTest>(TTest value)
{
return Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValue<TTest>(Context, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValue<TTest>(Context, value);
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
public TOut Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints<TIn, TOut>(TIn arg)
where TIn : class, new()
where TOut : System.Collections.ArrayList, System.IDisposable
{
return Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints<TIn, TOut>(Context, arg);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithGenericReturnValueAndTypeParamConstraints<TIn, TOut>(Context, arg);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void Generic_ExtensionMethodWithParameter<TTest>(TTest value)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithParameter<TTest>(Context, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Generic_ExtensionMethodWithParameter<TTest>(Context, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public dynamic NonGeneric_ExtensionMethodWithDynamicReturnValue()
{
return Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithDynamicReturnValue(Context);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithDynamicReturnValue(Context);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType(System.Collections.Generic.ICollection<Cake.Core.Tests.Data.MethodAliasGeneratorData.TestNestedEnum> items)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType(Context, items);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericCollectionOfNestedType(Context, items);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter(System.Linq.Expressions.Expression<System.Func<System.String, System.String>>[] expression)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter(Context, expression);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionArrayParameter(Context, expression);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithGenericExpressionParameter(System.Linq.Expressions.Expression<System.Func<System.String, System.String>> expression)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParameter(Context, expression);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParameter(Context, expression);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter(params System.Linq.Expressions.Expression<System.Func<System.String, System.String>>[] expression)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter(Context, expression);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericExpressionParamsArrayParameter(Context, expression);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithGenericParameter(System.Action<System.Int32> value)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericParameter(Context, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithGenericParameter(Context, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithNoParameters()
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNoParameters(Context);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNoParameters(Context);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithNullableParameter(System.String? parameter)
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNullableParameter(Context, parameter);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public System.String? NonGeneric_ExtensionMethodWithNullableReturnValue()
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithNullableReturnValue(Context);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalBooleanParameter(System.Int32 value, System.Boolean flag = false)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalBooleanParameter(Context, value, flag);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalBooleanParameter(Context, value, flag);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalCharParameter(System.String s, System.Char c = 's')
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalCharParameter(Context, s, c);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalCharParameter(Context, s, c);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalDecimalParameter(System.String s, System.Decimal value = (System.Decimal)12.12)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalDecimalParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalDecimalParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalEnumParameter(System.Int32 value, System.AttributeTargets targets = (System.AttributeTargets)4)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalEnumParameter(Context, value, targets);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalEnumParameter(Context, value, targets);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter(System.String s, System.Nullable<System.Boolean> value = (System.Boolean)false)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableBooleanParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableCharParameter(System.String s, System.Nullable<System.Char> value = (System.Char)'s')
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableCharParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableCharParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter(System.String s, System.Nullable<System.Decimal> value = (System.Decimal)123.12)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDecimalParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter(System.String s, System.Nullable<System.Double> value = (System.Double)1234567890.12)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableDoubleParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter(System.String s, System.Nullable<System.AttributeTargets> targets = (System.AttributeTargets)4)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter(Context, s, targets);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableEnumParameter(Context, s, targets);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableLongParameter(System.String s, System.Nullable<System.Int64> value = (System.Int64)1234567890)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableLongParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableLongParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalNullableTParameter(System.String s, System.Nullable<System.Int32> value = (System.Int32)0)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableTParameter(Context, s, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalNullableTParameter(Context, s, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalObjectParameter(System.Int32 value, System.Object option = null)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalObjectParameter(Context, value, option);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalObjectParameter(Context, value, option);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOptionalStringParameter(System.Int32 value, System.String s = "there is a \"string\" here and a \t tab")
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalStringParameter(Context, value, s);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOptionalStringParameter(Context, value, s);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithOutputParameter(out System.IDisposable arg)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOutputParameter(Context, out arg);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithOutputParameter(Context, out arg);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithParameter(System.Int32 value)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameter(Context, value);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameter(Context, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithParameterArray(params System.Int32[] values)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterArray(Context, values);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterArray(Context, values);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithParameterAttributes([System.Runtime.CompilerServices.CallerMemberName] System.String memberName = "", [System.Runtime.CompilerServices.CallerFilePath] System.String sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] System.Int32 sourceLineNumber = (System.Int32)0)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterAttributes(Context, memberName, sourceFilePath, sourceLineNumber);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithParameterAttributes(Context, memberName, sourceFilePath, sourceLineNumber);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void NonGeneric_ExtensionMethodWithReservedKeywordParameter(System.Int32 @new)
{
Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReservedKeywordParameter(Context, @new);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReservedKeywordParameter(Context, @new);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public System.String NonGeneric_ExtensionMethodWithReturnValue()
{
return Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReturnValue(Context);
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.NonGeneric_ExtensionMethodWithReturnValue(Context);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[System.Diagnostics.DebuggerStepThrough]
public void Obsolete_ExplicitError_WithMessage()
{
throw new Cake.Core.CakeException("The alias Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead.");
}
=> throw new Cake.Core.CakeException("The alias Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead.");
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[System.Diagnostics.DebuggerStepThrough]
public void Obsolete_ExplicitWarning_WithMessage()
{
Context.Log.Warning("Warning: The alias Obsolete_ExplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead.");
#pragma warning disable 0618
Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ExplicitWarning_WithMessage(Context);
#pragma warning restore 0618
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ExplicitWarning_WithMessage(Context);
#pragma warning restore 0618
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[System.Diagnostics.DebuggerStepThrough]
public void Obsolete_ImplicitWarning_NoMessage()
{
Context.Log.Warning("Warning: The alias Obsolete_ImplicitWarning_NoMessage has been made obsolete.");
#pragma warning disable 0618
Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_NoMessage(Context);
#pragma warning restore 0618
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_NoMessage(Context);
#pragma warning restore 0618
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[System.Diagnostics.DebuggerStepThrough]
public void Obsolete_ImplicitWarning_WithMessage()
{
Context.Log.Warning("Warning: The alias Obsolete_ImplicitWarning_WithMessage has been made obsolete. Please use Foo.Bar instead.");
#pragma warning disable 0618
Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_WithMessage(Context);
#pragma warning restore 0618
}
=> Cake.Core.Tests.Data.MethodAliasGeneratorData.Obsolete_ImplicitWarning_WithMessage(Context);
#pragma warning restore 0618
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
public System.Int32 Cached_Obsolete_ExplicitError_WithMessage
{
[System.Diagnostics.DebuggerStepThrough]
get
{
throw new Cake.Core.CakeException("The alias Cached_Obsolete_ExplicitError_WithMessage has been made obsolete. Please use Foo.Bar instead.");
}
}
[Obsolete("Please use Foo.Bar instead.", true)]
public System.Int32 Cached_Obsolete_ExplicitError_WithMessage
#pragma warning disable CS0618
=> Cake.Core.Tests.Data.PropertyAliasGeneratorData.Cached_Obsolete_ExplicitError_WithMessage(Context);
#pragma warning restore CS0618
Loading

0 comments on commit a9d5d99

Please sign in to comment.