in utilities/Microsoft.Quantum.Katas/CheckKataMagic.cs [107:139]
public virtual string Compile(string code, IChannel channel)
{
try
{
var result = Compiler.IdentifyElements(code);
// Gets the names of all the operations found for this snippet
var opsNames =
result
.Where(e => e.IsQsCallable)
.Select(e => e.ToFullName().WithoutNamespace(Microsoft.Quantum.IQSharp.Snippets.SNIPPETS_NAMESPACE))
.OrderBy(o => o)
.ToArray();
if (opsNames.Length > 1)
{
channel.Stdout("Expecting only one Q# operation in code. Using the first one");
}
return opsNames.First();
}
catch (CompilationErrorsException c)
{
foreach (var m in c.Errors) channel.Stderr(m);
return null;
}
catch (Exception e)
{
Logger?.LogWarning(e, "Unexpected error.");
channel.Stderr(e.Message);
return null;
}
}