swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

API client logs [csharp-client]

Open iamkarlson opened this issue 8 years ago • 11 comments

Add logs for most common operations. To implement logging, it's required to implement partial methods of Logger.cs #5355 suggestion issue

It's a second attempt to implement logs. The previous one ( #5424 ) had a lot of comments and suggestions from @wing328 and from @jimschubert . The fastest way is to throw all my changes out (which I made when mistakenly thought they would improve the client) and make only required functions. Please review again and give feedback.

iamkarlson avatar May 23 '17 09:05 iamkarlson

@iamkarlson thanks for the PR. I'll review later this week.

wing328 avatar Jun 05 '17 17:06 wing328

@iamkarlson Please run .\bin\windows\csharp-petstore-all.bat to update the C# Petstore samples.

I got compilation errors after updating the samples:

Using shared compilation with compiler from directory: C:\Program Files (x86)\MSBuild\14.0\Bin
Client\ApiClient.cs(203,58): error CS1026: ) expected [C:\projects\swagger-codegen-wh2wu\samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj]
Client\ApiClient.cs(211,37): error CS1002: ; expected [C:\projects\swagger-codegen-wh2wu\samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj]
Client\ApiClient.cs(241,43): error CS1002: ; expected [C:\projects\swagger-codegen-wh2wu\samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj]
Client\Configuration.cs(53,44): error CS1002: ; expected [C:\projects\swagger-codegen-wh2wu\samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj]
Done Building Project "C:\projects\swagger-codegen-wh2wu\samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj" (default targets) -- FAILED.

Ref: https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu/build/iamkarlson-logs_csharp-4170

wing328 avatar Jun 15 '17 07:06 wing328

@wing328 I tried to update samples but got an error with enum class. So I don't know is it my configuration or something wrong with code but appveyor built solution properly and there are no errors.

Could you check it again? If it's still impossible to push these changes without updating samples I'll check out my branch from scratch and run again. however, it can take time..

iamkarlson avatar Jun 22 '17 08:06 iamkarlson

@wing328 So, I clean my local repo and then go step by step. I suppose I fixed all issues, pls review.

iamkarlson avatar Jun 22 '17 09:06 iamkarlson

@iamkarlson thanks for fix. Most issues are gone except the following: screen shot 2017-06-28 at 5 31 06 pm

I'm using Xamarin 6.2 on MacOS with Mono 4.8.1

Did you get similar error locally?

CI (AppVeyor) also reports similar issues: https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu/build/iamkarlson-logs_csharp-4358

wing328 avatar Jun 28 '17 09:06 wing328

Those errors should occur on IDEs in Windows as well. A partial is like an interface which defaults to no implementation, so I'd expect the same errors you'd have for interfaces.

jimschubert avatar Jun 28 '17 12:06 jimschubert

@jimschubert do you remember you asked me in previous pr why I used public methods for wrappers? here That's why. I've remembered.

iamkarlson avatar Jun 28 '17 12:06 iamkarlson

@iamkarlson Sorry my comment on your previous PR wasn't clear.

Do you think it would make more sense to have

public void Trace(string message)
{
    TraceHandler(message);
}

partial void TraceHandler(string message);

This way you have the Trace method consumed by the client code as you have now, and you have the partial extension point as you had before but it's not embedding C# keywords TracePartial as it was before. This naming of TracePartial was my main concern and I didn't convey it correctly, sorry about that (I reread my post and I had a lot of stuff in that comment that was very confusing).

jimschubert avatar Jun 28 '17 13:06 jimschubert

@jimschubert I'll try to work it out upcoming week. Maybe I'll find out another workaround

iamkarlson avatar Jul 01 '17 06:07 iamkarlson

Sounds good. I'll review again later, then. Sorry again for any confusion my comments on your other PR may have caused.

jimschubert avatar Jul 01 '17 11:07 jimschubert

@jimschubert I haven't found out any other workaround for that. Only public wrappers for partial methods. Pls review

iamkarlson avatar Jul 24 '17 12:07 iamkarlson