Skip to content

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Dec 14, 2023

In this PR we update all the C# generated stubs.
The process was as follows

  1. Delete all stub folders in test/resources/stubs
  2. Run the make_stubs_all.py script and copy all the generated stubs to test/resources/stubs and add everything to the repo.
  3. Update all options files to point to the new version of the stubs.
  4. Make needed manual adjustments to generated and handwritten stubs to get everything to compile again <-- I think this is currently the closest we have been to able to automate the process.

A couple of interesting possibilities for improvements

  • The version numbers may be printed incorrectly in the .csproj files (I think this is due to ranges being used).
  • The appears to be some garbage stub code generated for the ServiceStack framework (I will look into this if time allows it).

@github-actions github-actions bot added the C# label Dec 14, 2023
@michaelnebel michaelnebel force-pushed the csharp/stubsrefresh branch 4 times, most recently from 1a71142 to 118238c Compare December 15, 2023 08:19
@michaelnebel michaelnebel changed the title C#: Stubs refresh. C#: .NET8 Stubs update. Dec 15, 2023
@michaelnebel michaelnebel marked this pull request as ready for review December 15, 2023 09:23
@michaelnebel michaelnebel requested a review from a team as a code owner December 15, 2023 09:23
@@ -1436,15 +1436,11 @@ public class DefaultScripts : ServiceStack.Script.ScriptMethods, ServiceStack.Sc
public long decrBy(long value, long by) => throw null;
public long decrement(long value) => throw null;
public long decrementBy(long value, long by) => throw null;
public object default(object returnTarget, object elseReturn) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because the stubgenerator fails to escape the name as @default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I definitely thinks that is the case: https://github.com/ServiceStack/ServiceStack/blob/8134c682b3074b3e9525a269b8ba66427fee10e7/ServiceStack/src/ServiceStack.Common/Script/Methods/DefaultScripts.cs#L1630

I intend to do some follow up work on the stub generator to fix this.

public System.Collections.Generic.IEnumerable<object> distinct(System.Collections.Generic.IEnumerable<object> items) => throw null;
public double div(double lhs, double rhs) => throw null;
public double divide(double lhs, double rhs) => throw null;
public object do(ServiceStack.Script.ScriptScopeContext scope, object expression) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, @do.

@@ -1562,9 +1558,7 @@ public class DefaultScripts : ServiceStack.Script.ScriptMethods, ServiceStack.Sc
public string httpPathInfo(ServiceStack.Script.ScriptScopeContext scope) => throw null;
public string httpRequestUrl(ServiceStack.Script.ScriptScopeContext scope) => throw null;
public string humanize(string text) => throw null;
public object if(object test) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -1846,10 +1840,7 @@ public class DefaultScripts : ServiceStack.Script.ScriptMethods, ServiceStack.Sc
public object resolveContextArg(ServiceStack.Script.ScriptScopeContext scope, string name) => throw null;
public object resolveGlobal(ServiceStack.Script.ScriptScopeContext scope, string name) => throw null;
public object resolvePageArg(ServiceStack.Script.ScriptScopeContext scope, string name) => throw null;
public ServiceStack.Script.StopExecution return(ServiceStack.Script.ScriptScopeContext scope) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -1939,9 +1930,7 @@ public class DefaultScripts : ServiceStack.Script.ScriptMethods, ServiceStack.Sc
public System.Collections.Generic.IEnumerable<object> thenByDescending(ServiceStack.Script.ScriptScopeContext scope, object target, object expression) => throw null;
public System.Collections.Generic.IEnumerable<object> thenByDescending(ServiceStack.Script.ScriptScopeContext scope, object target, object expression, object scopeOptions) => throw null;
public static System.Collections.Generic.IEnumerable<object> thenByInternal(string filterName, ServiceStack.Script.ScriptScopeContext scope, object target, object expression, object scopeOptions) => throw null;
public object throw(ServiceStack.Script.ScriptScopeContext scope, string message) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -3265,9 +3253,7 @@ public class ProtectedScripts : ServiceStack.Script.ScriptMethods
public ServiceStack.Script.IgnoreResult Move(string from, string to) => throw null;
public ServiceStack.Script.IgnoreResult Move(ServiceStack.Script.IOScript os, string from, string to) => throw null;
public string mv(ServiceStack.Script.ScriptScopeContext scope, string from, string to) => throw null;
public object new (string typeName) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -3298,8 +3284,7 @@ public class ProtectedScripts : ServiceStack.Script.ScriptMethods
public string textContents(ServiceStack.IO.IVirtualFile file) => throw null;
public string touch(ServiceStack.Script.ScriptScopeContext scope, string target) => throw null;
public static string TypeNotFoundErrorMessage(string typeName) => throw null;
public System.Type typeof(string typeName) => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -1042,8 +1042,7 @@ public static partial class ListExtensions
}
public class LongRange : System.IEquatable<ServiceStack.LongRange>
{
public virtual ServiceStack.LongRange<Clone>$() => throw null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the stub generator should not emit this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into this problem as well (it is different from the previous ones).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the a "clone" method is created for record class. It can't be invoked directly (only implicitly via the r with { ... } expression, so we should just avoid generating it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on what our goal is, it might not be enough to remove this method from the stubs.

The with { ... } expression can only be used with records. So if this class is not generated as a record class, then we won't be able to write new LongRange() with { ... } in the test files. (But I think we can live with this limitation)

@michaelnebel michaelnebel merged commit d59b5a9 into github:main Dec 15, 2023
@michaelnebel michaelnebel deleted the csharp/stubsrefresh branch December 15, 2023 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants