public RepeatedField<SourceCodeInfo.Types.Location> Location { get; }
A Location identifies a piece of source code in a .proto file which
corresponds to a particular definition. This information is intended
to be useful to IDEs, code indexers, documentation generators, and similar
tools.
For example, say we have a file like:
message Foo {
optional string foo = 1;
}
Let's look at just the field definition:
optional string foo = 1;
^ ^^ ^^ ^ ^^^
a bc de f ghi
We have the following locations:
span path represents
[a,i) [ 4, 0, 2, 0 ] The whole field definition.
[a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
[c,d) [ 4, 0, 2, 0, 5 ] The type (string).
[e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
[g,h) [ 4, 0, 2, 0, 3 ] The number (1).
Notes:
A location may refer to a repeated field itself (i.e. not to any
particular index within it). This is used whenever a set of elements are
logically enclosed in a single code segment. For example, an entire
extend block (possibly containing multiple extension definitions) will
have an outer location whose path refers to the "extensions" repeated
field without an index.
Multiple locations may have the same path. This happens when a single
logical declaration is spread out across multiple places. The most
obvious example is the "extend" block again -- there may be multiple
extend blocks in the same scope, each of which will have the same path.
A location's span is not always a subset of its parent's span. For
example, the "extendee" of an extension declaration appears at the
beginning of the "extend" block and is shared by all extensions within
the block.
Just because a location's span is a subset of some other location's span
does not mean that it is a descendant. For example, a "group" defines
both a type and a field in a single declaration. Thus, the locations
corresponding to the type and field and their components will overlap.
Code which tries to interpret locations should probably be designed to
ignore those that it doesn't understand, as more types of locations could
be recorded in the future.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eSourceCodeInfo\u003c/code\u003e is a class that encapsulates information about the original source file of a \u003ccode\u003eFileDescriptorProto\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of \u003ccode\u003eSourceCodeInfo\u003c/code\u003e is 3.27.1, with other versions available being 3.23.0 and 3.15.8.\u003c/p\u003e\n"],["\u003cp\u003eThis class implements interfaces such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSourceCodeInfo\u003c/code\u003e contains a \u003ccode\u003eLocation\u003c/code\u003e property, which identifies specific pieces of source code in a .proto file, useful for tools like IDEs and code indexers.\u003c/p\u003e\n"],["\u003cp\u003eThe class includes methods for managing data, like \u003ccode\u003eCalculateSize\u003c/code\u003e, \u003ccode\u003eClone\u003c/code\u003e, \u003ccode\u003eEquals\u003c/code\u003e, \u003ccode\u003eMergeFrom\u003c/code\u003e, \u003ccode\u003eWriteTo\u003c/code\u003e, as well as constructors for initialization.\u003c/p\u003e\n"]]],[],null,["# Class SourceCodeInfo (3.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [3.27.1 (latest)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.SourceCodeInfo)\n- [3.23.0](/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.Reflection.SourceCodeInfo)\n- [3.15.8](/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.Reflection.SourceCodeInfo) \n\n public sealed class SourceCodeInfo : IMessage\u003cSourceCodeInfo\u003e, IEquatable\u003cSourceCodeInfo\u003e, IDeepCloneable\u003cSourceCodeInfo\u003e, IBufferMessage, IMessage\n\nEncapsulates information about the original source file from which a\nFileDescriptorProto was generated. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SourceCodeInfo \n\nImplements\n----------\n\n[IMessage](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1)[SourceCodeInfo](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.SourceCodeInfo), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[SourceCodeInfo](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.SourceCodeInfo), [IDeepCloneable](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1)[SourceCodeInfo](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.SourceCodeInfo), [IBufferMessage](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage), [IMessage](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage) \n\nInherited Members\n-----------------\n\n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)\n\nNamespace\n---------\n\n[Google.Protobuf.Reflection](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection)\n\nAssembly\n--------\n\nGoogle.Protobuf.dll\n\nConstructors\n------------\n\n### SourceCodeInfo()\n\n public SourceCodeInfo()\n\n### SourceCodeInfo(SourceCodeInfo)\n\n public SourceCodeInfo(SourceCodeInfo other)\n\nFields\n------\n\n### LocationFieldNumber\n\n public const int LocationFieldNumber = 1\n\nField number for the \"location\" field.\n\nProperties\n----------\n\n### Descriptor\n\n public static MessageDescriptor Descriptor { get; }\n\n### Location\n\n public RepeatedField\u003cSourceCodeInfo.Types.Location\u003e Location { get; }\n\nA Location identifies a piece of source code in a .proto file which\ncorresponds to a particular definition. This information is intended\nto be useful to IDEs, code indexers, documentation generators, and similar\ntools.\n\nFor example, say we have a file like:\nmessage Foo {\noptional string foo = 1;\n}\nLet's look at just the field definition:\noptional string foo = 1;\n\\^ \\^\\^ \\^\\^ \\^ \\^\\^\\^\na bc de f ghi\nWe have the following locations:\nspan path represents\n\\[a,i) \\[ 4, 0, 2, 0 \\] The whole field definition.\n\\[a,b) \\[ 4, 0, 2, 0, 4 \\] The label (optional).\n\\[c,d) \\[ 4, 0, 2, 0, 5 \\] The type (string).\n\\[e,f) \\[ 4, 0, 2, 0, 1 \\] The name (foo).\n\\[g,h) \\[ 4, 0, 2, 0, 3 \\] The number (1).\n\nNotes:\n\n- A location may refer to a repeated field itself (i.e. not to any particular index within it). This is used whenever a set of elements are logically enclosed in a single code segment. For example, an entire extend block (possibly containing multiple extension definitions) will have an outer location whose path refers to the \"extensions\" repeated field without an index.\n- Multiple locations may have the same path. This happens when a single logical declaration is spread out across multiple places. The most obvious example is the \"extend\" block again -- there may be multiple extend blocks in the same scope, each of which will have the same path.\n- A location's span is not always a subset of its parent's span. For example, the \"extendee\" of an extension declaration appears at the beginning of the \"extend\" block and is shared by all extensions within the block.\n- Just because a location's span is a subset of some other location's span does not mean that it is a descendant. For example, a \"group\" defines both a type and a field in a single declaration. Thus, the locations corresponding to the type and field and their components will overlap.\n- Code which tries to interpret locations should probably be designed to ignore those that it doesn't understand, as more types of locations could be recorded in the future.\n\n### Parser\n\n public static MessageParser\u003cSourceCodeInfo\u003e Parser { get; }\n\nMethods\n-------\n\n### CalculateSize()\n\n public int CalculateSize()\n\nCalculates the size of this message in Protocol Buffer wire format, in bytes.\n\n### Clone()\n\n public SourceCodeInfo Clone()\n\nCreates a deep clone of this object.\n\n### Equals(SourceCodeInfo)\n\n public bool Equals(SourceCodeInfo other)\n\n### Equals(object)\n\n public override bool Equals(object other)\n\n**Overrides** \n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object))\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### MergeFrom(CodedInputStream)\n\n public void MergeFrom(CodedInputStream input)\n\nMerges the data from the specified coded input stream with the current message.\n\n**Remarks** \nSee the user guide for precise merge semantics.\n\n### MergeFrom(SourceCodeInfo)\n\n public void MergeFrom(SourceCodeInfo other)\n\nMerges the given message into this one.\n\n**Remarks** \nSee the user guide for precise merge semantics.\n\n### ToString()\n\n public override string ToString()\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### WriteTo(CodedOutputStream)\n\n public void WriteTo(CodedOutputStream output)\n\nWrites the data to the given coded output stream.\n\nExtension Methods\n-----------------\n\n[MessageExtensions.IsInitialized(IMessage)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_IsInitialized_Google_Protobuf_IMessage_) \n[MessageExtensions.MergeDelimitedFrom(IMessage, Stream)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeDelimitedFrom_Google_Protobuf_IMessage_System_IO_Stream_) \n[MessageExtensions.MergeFrom(IMessage, ByteString)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeFrom_Google_Protobuf_IMessage_Google_Protobuf_ByteString_) \n[MessageExtensions.MergeFrom(IMessage, ReadOnlySequence\\\u003cbyte\\\u003e)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeFrom_Google_Protobuf_IMessage_System_Buffers_ReadOnlySequence_System_Byte__) \n[MessageExtensions.MergeFrom(IMessage, byte\\[\\])](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeFrom_Google_Protobuf_IMessage_System_Byte___) \n[MessageExtensions.MergeFrom(IMessage, byte\\[\\], int, int)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeFrom_Google_Protobuf_IMessage_System_Byte___System_Int32_System_Int32_) \n[MessageExtensions.MergeFrom(IMessage, Stream)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeFrom_Google_Protobuf_IMessage_System_IO_Stream_) \n[MessageExtensions.MergeFrom(IMessage, ReadOnlySpan\\\u003cbyte\\\u003e)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_MergeFrom_Google_Protobuf_IMessage_System_ReadOnlySpan_System_Byte__) \n[MessageExtensions.ToByteArray(IMessage)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_ToByteArray_Google_Protobuf_IMessage_) \n[MessageExtensions.ToByteString(IMessage)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_ToByteString_Google_Protobuf_IMessage_) \n[MessageExtensions.WriteDelimitedTo(IMessage, Stream)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_WriteDelimitedTo_Google_Protobuf_IMessage_System_IO_Stream_) \n[MessageExtensions.WriteTo(IMessage, IBufferWriter\\\u003cbyte\\\u003e)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_WriteTo_Google_Protobuf_IMessage_System_Buffers_IBufferWriter_System_Byte__) \n[MessageExtensions.WriteTo(IMessage, Stream)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_WriteTo_Google_Protobuf_IMessage_System_IO_Stream_) \n[MessageExtensions.WriteTo(IMessage, Span\\\u003cbyte\\\u003e)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.MessageExtensions#Google_Protobuf_MessageExtensions_WriteTo_Google_Protobuf_IMessage_System_Span_System_Byte__)"]]