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

C# GetOption: throws NullReferenceException #7222

Closed
zhxymh opened this issue Feb 17, 2020 · 2 comments
Closed

C# GetOption: throws NullReferenceException #7222

zhxymh opened this issue Feb 17, 2020 · 2 comments

Comments

@zhxymh
Copy link

zhxymh commented Feb 17, 2020

What version of protobuf and what language are you using?
Version: v3.11.4
Language: C#

What operating system (Linux, Windows, ...) and version?
mac 10.14.6

What runtime / compiler are you using (e.g., python version or gcc version)
.NET Core 3.1.0

What did you do?
Use method FileDescriptor.GetOption.

If the proto file sets the options, it works. But if it is not set, throws NullReferenceException

System.NullReferenceException : Object reference not set to an instance of an object.
   at Google.Protobuf.Reflection.FileDescriptor.GetOption[T](Extension`2 extension)
   at AElf.FileDescriptorExtensions.GetIdentity(FileDescriptor descriptor) in /Users/zhangxin/code/AElf/src/AElf.Types/Protobuf/FileDescriptorExtensions.cs:line 9

I think we should check if this.Proto.Options is null. If null, the default value is returned.

Google.Protobuf.Reflection.FileDescriptor.cs
image

@xtroncode
Copy link

#7130 Solves this but it hasn't been merged yet.

@zhxymh
Copy link
Author

zhxymh commented Mar 21, 2020

#7130 Solves this but it hasn't been merged yet.

Thx!

@elharo elharo closed this as completed Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants