| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Diagnostics; |
| | | 5 | | using System.Diagnostics.CodeAnalysis; |
| | | 6 | | using System.Reflection.Internal; |
| | | 7 | | |
| | | 8 | | namespace System.Reflection.Metadata |
| | | 9 | | { |
| | | 10 | | [DebuggerDisplay("{GetDebuggerDisplay(),nq}")] |
| | | 11 | | public readonly struct SequencePoint : IEquatable<SequencePoint> |
| | | 12 | | { |
| | | 13 | | public const int HiddenLine = 0xfeefee; |
| | | 14 | | |
| | 0 | 15 | | public DocumentHandle Document { get; } |
| | 0 | 16 | | public int Offset { get; } |
| | 0 | 17 | | public int StartLine { get; } |
| | 0 | 18 | | public int EndLine { get; } |
| | 0 | 19 | | public int StartColumn { get; } |
| | 0 | 20 | | public int EndColumn { get; } |
| | | 21 | | |
| | | 22 | | internal SequencePoint(DocumentHandle document, int offset) |
| | 0 | 23 | | { |
| | 0 | 24 | | Document = document; |
| | 0 | 25 | | Offset = offset; |
| | 0 | 26 | | StartLine = HiddenLine; |
| | 0 | 27 | | StartColumn = 0; |
| | 0 | 28 | | EndLine = HiddenLine; |
| | 0 | 29 | | EndColumn = 0; |
| | 0 | 30 | | } |
| | | 31 | | |
| | | 32 | | internal SequencePoint(DocumentHandle document, int offset, int startLine, ushort startColumn, int endLine, usho |
| | 0 | 33 | | { |
| | 0 | 34 | | Document = document; |
| | 0 | 35 | | Offset = offset; |
| | 0 | 36 | | StartLine = startLine; |
| | 0 | 37 | | StartColumn = startColumn; |
| | 0 | 38 | | EndLine = endLine; |
| | 0 | 39 | | EndColumn = endColumn; |
| | 0 | 40 | | } |
| | | 41 | | |
| | | 42 | | public override int GetHashCode() |
| | 0 | 43 | | { |
| | 0 | 44 | | return Hash.Combine(Document.RowId, |
| | 0 | 45 | | Hash.Combine(Offset, |
| | 0 | 46 | | Hash.Combine(StartLine, |
| | 0 | 47 | | Hash.Combine(StartColumn, |
| | 0 | 48 | | Hash.Combine(EndLine, EndColumn))))); |
| | 0 | 49 | | } |
| | | 50 | | |
| | | 51 | | public override bool Equals([NotNullWhen(true)] object? obj) |
| | 0 | 52 | | { |
| | 0 | 53 | | return obj is SequencePoint sequencePoint && Equals(sequencePoint); |
| | 0 | 54 | | } |
| | | 55 | | |
| | | 56 | | public bool Equals(SequencePoint other) |
| | 0 | 57 | | { |
| | 0 | 58 | | return Document == other.Document |
| | 0 | 59 | | && Offset == other.Offset |
| | 0 | 60 | | && StartLine == other.StartLine |
| | 0 | 61 | | && StartColumn == other.StartColumn |
| | 0 | 62 | | && EndLine == other.EndLine |
| | 0 | 63 | | && EndColumn == other.EndColumn; |
| | 0 | 64 | | } |
| | | 65 | | |
| | 0 | 66 | | public bool IsHidden => StartLine == 0xfeefee; |
| | | 67 | | |
| | | 68 | | private string GetDebuggerDisplay() |
| | 0 | 69 | | { |
| | 0 | 70 | | return IsHidden ? "<hidden>" : $"{Offset}: ({StartLine}, {StartColumn}) - ({EndLine}, {EndColumn})"; |
| | 0 | 71 | | } |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | |