Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid creating unnecessary intermediate strings (#3439)
* Refactor JSON serialization to use MemoryStream Replaced StringWriter with MemoryStream and StreamWriter for JSON serialization to improve efficiency. JsonWriter is now initialized with StreamWriter. Adjusted indentation levels in ProcessStructure and ProcessMembers methods. Final request content is now obtained as a byte array from MemoryStream. * Update generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.tt Co-authored-by: Stuart Lang <[email protected]> * Update generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCRequestMarshaller.tt Co-authored-by: Stuart Lang <[email protected]> * Simplify StreamWriter instantiation Refactor the instantiation of the `StreamWriter` object within a `using` statement by removing unnecessary parameters. The original code included `null` for encoding, `-1` for buffer size, and `true` for leaving the stream open. The updated code uses the default constructor, which only requires the `MemoryStream` object, as the default behavior is sufficient for the intended use case. * Add InvariantCultureStreamWriter for consistent formatting Introduce InvariantCultureStreamWriter class to enforce invariant culture formatting. Replace StreamWriter with InvariantCultureStreamWriter in JsonRPCRequestMarshaller.tt to ensure consistent JSON formatting regardless of system culture. --------- Co-authored-by: Stuart Lang <[email protected]>
- Loading branch information