Git Product home page Git Product logo

kiota-serialization-text-dotnet's Introduction

Kiota Text Serialization Library for dotnet

Build and Test NuGet Version

The Text Serialization Library for dotnet is the dotnet Text serialization library implementation to handle text/plain responses.

A Kiota generated project will need a reference to a Text serialization package to handle text/plain payloads from an API endpoint.

Read more about Kiota here.

Using the Kiota Text Serialization Library

dotnet add package Microsoft.Kiota.Serialization.Text --prerelease

Debugging

If you are using Visual Studio Code as your IDE, the launch.json file already contains the configuration to build and test the library. Otherwise, you can open the Microsoft.Kiota.Serialization.Text.sln with Visual Studio.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

kiota-serialization-text-dotnet's People

Contributors

andrueastman avatar baywet avatar czemacleod avatar dependabot[bot] avatar github-actions[bot] avatar hwoodiwiss avatar ievangelist avatar jasonjoh avatar microsoft-github-operations[bot] avatar microsoftopensource avatar mihamarkic avatar samwelkanda avatar thompson-tomo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kiota-serialization-text-dotnet's Issues

TextSerializationWriter should not use System.Text.Encoding.UTF8

In #83, a change was made to the MemoryStream used by the TextSerializationWriter to leave the underlying Stream open. Specifically, the change was to pass the leaveOpen parameter as true.

This was done for .NET like so:

writer = new(_stream, leaveOpen: true);

This skipped the two optional parameters between the stream and leaveOpen: encoding and bufferSize, so that the default values of these parameters would be used.

However, the testing section of the "Build and Test" action runs tests under the .NET Framework 4.6.2, which doesn't compile if you skip optional parameters. The attempt to address this was to change to:

writer = new(
    _stream,
    // Default encoding
    encoding: System.Text.Encoding.UTF8,
    // Default buffer size
    bufferSize: 1024,
    leaveOpen: true);

However, it turns out that default encoding actually is not System.Text.Encoding.UTF8. It's a custom encoding:

https://referencesource.microsoft.com/#mscorlib/system/io/streamwriter.cs,106

UTF8Encoding noBOM = new UTF8Encoding(false, true);

Package should be using a license expression

Summary

I wish for the nuget packages to have the licence expression property set correctly

Details

The licence expression property should be set to the correct licence type I.e. MIT as this will enable analysis of licences in use to occur in external tools & the license type will be shown in Nuget etc.

TextSerializationWriter results in System.Net.Http.HttpRequestException

An exception of type 'System.Net.Http.HttpRequestException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Error while copying content to a stream.'
 Inner exceptions found, see $exception in variables window for more details.
 Innermost exception 	 System.ObjectDisposedException : Cannot access a closed Stream.
   at System.ThrowHelper.ThrowObjectDisposedException_StreamClosed(String objectName)
   at System.IO.MemoryStream.CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
   at System.Net.Http.StreamToStreamCopy.CopyAsync(Stream source, Stream destination, Int32 bufferSize, Boolean disposeSource, CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at System.Net.Http.HttpContent.<<CopyToAsync>g__WaitAsync|56_0>d.MoveNext()

Cause:

public void Dispose()
{
_stream?.Dispose();
writer?.Dispose();
GC.SuppressFinalize(this);
}

  • _stream?.Dispose() closes the stream.
  • writer?.Dispose() also closes the stream (so just removing the _stream?.Dispose() call won't suffice)

Fix:

  • Remove _stream?.Dispose() line.

  • In TextSerializationWriter constructor, pass leaveOpen: true to the constructor of the StreamWriter.:

    writer = new(_stream, leaveOpen: true);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.