docs
docs copied to clipboard
What about `short`/`Int16`?
So many other int types here but not an int16
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: c2a41d02-3084-c31e-98ed-2bd786c7a301
- Version Independent ID: 31a20696-f326-63c3-77d1-f3cfc0aa589c
- Content: Protobuf scalar data types - gRPC for WCF developers
- Content Source: docs/architecture/grpc-for-wcf-developers/protobuf-data-types.md
- Product: dotnet-architecture
- Technology: grpc
- GitHub Login: @shirhatti
- Microsoft Alias: soshir
Hi @StingyJack, thank you for reaching out.
gRPC/Protobuf doesn't support 16-bits integer. For the list of supported scalar value types, please refer Scalar Value Types - Protobuf Language Guide (proto3) or Supported Scalar Value Types
To add to reply above, protobuf uses a variable length encoding for integers. Assuming your goal was to optimize the wire transmission, forcing a smaller width integer isn't needed.
This document describes the difference in type systems and offers suggestions for other primitive types but it does not cover short/int16.
Data lost from a narrowing conversion is the concern. I don't always have control over the existing model types. Best I can come up with is when the model property is a short and the incoming value is > short.MaxValue to throw an exception. Curious to hear about alternative approaches.
Data lost from a narrowing conversion is the concern. I don't always have control over the existing model types. Best I can come up with is when the model property is a short and the incoming value is > short.MaxValue to throw an exception. Curious to hear about alternative approaches.
I was about to suggest something along those lines. @JamesNK anything to add?
Considering the original issue is answered and it's open for a very long, this can be closed now.
@erjain - This was opened to get the documentation updated to include the appropriate advice. Its not a support issue that can be resolved when a solution can be given.
Sure @StingyJack. Hi @JamesNK, any suggestions?
Closing this issue, as it relates to an eBook that has since been archived. For more information, see:
- Issue: #38774
- Pull request: #38775