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

Another VS 2015 Compatibility bug #35

Closed
jeff-r-koyaltech opened this issue Jun 29, 2015 · 2 comments
Closed

Another VS 2015 Compatibility bug #35

jeff-r-koyaltech opened this issue Jun 29, 2015 · 2 comments
Labels

Comments

@jeff-r-koyaltech
Copy link

I was using the proto found here:
https://github.com/WhisperSystems/libaxolotl-java/blob/master/protobuf/LocalStorageProtocol.proto

And this generated code is causing an error because there is no GetBuffer() method on the Stream.

Severity Code Description Project File Line
Error CS1061 'MemoryStream' does not contain a definition for 'GetBuffer' and no extension method 'GetBuffer' accepting a first argument of type 'MemoryStream' could be found (are you missing a using directive or an assembly reference?) libaxolotl-csharp C:\Users\Jeff\Source\Repos\libaxolotl-windows\libaxolotl-csharp\Protobuf\LocalStorageProtocol.Serializer.cs 393

if (instance.SenderChain != null)
{
// Key for field: 6, LengthDelimited
stream.WriteByte(50);
msField.SetLength(0);
Textsecure.SessionStructure.Chain.Serialize(msField, instance.SenderChain);
// Length delimited byte array
uint length6 = (uint)msField.Length;
global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length6);
stream.Write(msField.GetBuffer(), 0, (int)length6);

        }

On the surface, the fix seems to be the use of CopyTo() instead of GetBuffer(), although I am still testing this change to be sure.
Example:
msField.CopyTo(stream, (int)length6);

@hultqvist hultqvist added the Bug label Jul 4, 2015
@hultqvist
Copy link
Collaborator

I've previously tried a few different methods where CopyTo was one of them but it was one of the slower ones.

Another, possible better, solution is to use WriteTo, would that compile on your target platform?

@jeff-r-koyaltech
Copy link
Author

Hi Peter,

WriteTo is available. It takes a stream just like your documentation link
shows. In general, it seems that if a method is available on .NET 4.6 and a
method is also available for Portable Class Libraries, it should compile in
my environment.

Thanks,
Jeff

On Wed, Jul 8, 2015 at 11:09 AM, Peter Hultqvist notifications@github.com
wrote:

I've previously tried a few different methods
https://github.com/hultqvist/ProtoBuf/blob/master/CodeGenerator/CodeGenerator/FieldSerializer.cs#L237
where CopyTo was one of them but it was one of the slower ones.

Another, possible better, solution is to use WriteTo
https://msdn.microsoft.com/en-us/library/system.io.memorystream.writeto(v=vs.110).aspx,
would that compile on your target platform?


Reply to this email directly or view it on GitHub
#35 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants