Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c#, improvements: small improvements including marking files internal + client classes partial #4248

Merged
merged 6 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace <%= namespace%>;
/// </summary>
/// <typeparam name="TDatatype">Type of item to convert.</typeparam>
/// <typeparam name="TConverterType">Converter to use for individual items.</typeparam>
public class CollectionItemSerializer<TDatatype, TConverterType>
internal class CollectionItemSerializer<TDatatype, TConverterType>
: JsonConverter<IEnumerable<TDatatype>>
where TConverterType : JsonConverter
{
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/asIs/DateTimeSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace <%= namespace%>;

public class DateTimeSerializer : JsonConverter<DateTime>
internal class DateTimeSerializer : JsonConverter<DateTime>
{
public override DateTime Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// Tolerant Enum converter. Based on code in the StackOverflow post below.
/// http://stackoverflow.com/questions/22752075/how-can-i-ignore-unknown-enum-values-during-json-deserialization
/// </summary>
class TolerantEnumConverter : JsonConverter
internal class TolerantEnumConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace <%= namespace%>;

public static class HttpMethodExtensions
internal static class HttpMethodExtensions
{
public static readonly HttpMethod Patch = new("PATCH");
}
4 changes: 2 additions & 2 deletions generators/csharp/codegen/src/asIs/JsonConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace <%= namespace%>;

public static class JsonOptions
internal static class JsonOptions
{
public static readonly JsonSerializerOptions JsonSerializerOptions;

Expand All @@ -16,7 +16,7 @@ static JsonOptions()
}
}

public static class JsonUtils
internal static class JsonUtils
{
public static string Serialize<T>(T obj)
{
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/codegen/src/asIs/OneOfSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace <%= namespace%>;

public class OneOfSerializer<TOneOf> : JsonConverter<TOneOf>
internal class OneOfSerializer<TOneOf> : JsonConverter<TOneOf>
where TOneOf : IOneOf
{
public override TOneOf? Read(
Expand Down
5 changes: 3 additions & 2 deletions generators/csharp/codegen/src/asIs/RawClient.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace <%= namespace%>;
/// <summary>
/// Utility class for making raw HTTP requests to the API.
/// </summary>
public class RawClient(
internal class RawClient(
Dictionary<string, string> headers,
Dictionary<string, Func<string>> headerSuppliers,
ClientOptions clientOptions
Expand Down Expand Up @@ -131,7 +131,8 @@ private string BuildUrl(BaseApiRequest request)
.Cast<object>()
.Select(value => $"{queryItem.Key}={value}")
.ToList();
if (items.Any()) {
if (items.Any())
{
current += string.Join("&", items) + "&";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace <%= namespace%>

[JsonConverter(typeof(TolerantEnumConverter))]
public class StringEnum<T> where T : System.Enum
internal class StringEnum<T> where T : System.Enum
{
public readonly T value;
public readonly String _raw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace <%= namespace%>;

public class StringEnumSerializer<TEnum> : JsonConverter<TEnum>
internal class StringEnumSerializer<TEnum> : JsonConverter<TEnum>
where TEnum : struct, System.Enum
{
private readonly Dictionary<TEnum, string> _enumToString = new();
Expand Down
5 changes: 3 additions & 2 deletions generators/csharp/codegen/src/ast/Access.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type Access = "public" | "private";
export type Access = "public" | "private" | "internal";

export const Access = {
Public: "public",
Private: "private"
Private: "private",
Internal: "internal"
} as const;
6 changes: 6 additions & 0 deletions generators/csharp/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.11.0 - 2024-08-09]

- Improvement: Mark internal files `internal`.
- Improvement: Make all client classes `Partial`.
- Improvement: Don't override `toString` on Exceptions

## [0.10.0 - 2024-08-07]

- Fix: Fix a bug where conflicting class names and namespaces cause compile to fail.
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.0
0.11.0
13 changes: 0 additions & 13 deletions generators/csharp/sdk/src/error/BaseApiExceptionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ export class BaseApiExceptionGenerator extends FileGenerator<CSharpFile, SdkCust
summary: "The body of the response that triggered the exception."
})
);
class_.addMethod(
csharp.method({
name: "ToString",
access: "public",
isAsync: false,
parameters: [],
override: true,
body: csharp.codeblock(
`return $"${class_.name} {{ message: {Message}, statusCode: {StatusCode}, body: {Body} }}";`
),
return_: csharp.Type.string()
})
);
return new CSharpFile({
clazz: class_,
directory: this.context.getCoreDirectory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SubPackageClientGenerator extends FileGenerator<CSharpFile, SdkCust
public doGenerate(): CSharpFile {
const class_ = csharp.class_({
...this.classReference,
partial: false,
partial: true,
access: "public"
});

Expand Down Expand Up @@ -84,7 +84,7 @@ export class SubPackageClientGenerator extends FileGenerator<CSharpFile, SdkCust

private getConstructorMethod(): csharp.Class.Constructor {
return {
access: "public",
access: "internal",
parameters: [
csharp.parameter({
name: "client",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading