Skip to content
← Back

src/semantic/dotnet/session_cell_marker.ghul

1
@@IF.dotnet()
2
3
namespace Semantic.DotNet is
4
use System.Reflection.Assembly
5
6
// How a REPL cell's assembly says it is one: an AssemblyMetadata
7
// entry under a key only `--submission` writes, whose value is the
8
// cell's name.
9
class SESSION_CELL_MARKER is
10
KEY: string static => "ghul.submission"
11
12
ATTRIBUTE_NAME: string static => "System.Reflection.AssemblyMetadataAttribute"
13
14
is_marked(assembly: Assembly) -> bool static is
15
for data in assembly.get_custom_attributes_data() do
16
if data.attribute_type.full_name =~ ATTRIBUTE_NAME /\ data.constructor_arguments.count == 2 then
17
let key = data.constructor_arguments[0].value
18
19
if let text: string = key then
20
if text =~ KEY then
21
return true
22
fi
23
fi
24
fi
25
od
26
27
return false
28
si
29
si
30
si