Files
sbox-public/engine/Sandbox.Access/AssemblyAccess.Location.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

36 lines
932 B
C#

using Mono.Cecil.Cil;
using Microsoft.CodeAnalysis.Text;
using System;
namespace Sandbox;
internal partial class AssemblyAccess
{
[ThreadStatic]
protected static AccessControl.CodeLocation Location;
private void UpdateLocation( SequencePoint sequencePoint )
{
if ( sequencePoint == null )
return;
if ( sequencePoint.IsHidden )
{
Location = new AccessControl.CodeLocation( $"{sequencePoint.Document.Url}:{sequencePoint.StartLine}" );
return;
}
// Roslyn is zero based, Mono.Cecil is one based
var start = new LinePosition( sequencePoint.StartLine - 1, sequencePoint.StartColumn - 1 );
var end = new LinePosition( sequencePoint.EndLine - 1, sequencePoint.EndColumn - 1 );
var location = Microsoft.CodeAnalysis.Location.Create(
sequencePoint.Document.Url,
textSpan: default,
lineSpan: new LinePositionSpan( start, end )
);
Location = new AccessControl.CodeLocation( location );
}
}