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