/// <summary>
        /// Initializes the entry point from already loaded assembly.
        /// </summary>
        /// <param name="asm">The assembly.</param>
        public void InitializeEntryPoint(Assembly asm)
        {
            if (asm == null)
            {
                throw new ArgumentNullException("Assembly");
            }

            _compilation = GetCompilation();

            // If assembly is present, that means compilation was successful.
            IsCompilationSuccessful = true;

            try
            {
                memberInfo = _compilation.GetEntryPoint(asm);
                InitializeAttributes();
            }
            catch (Exception ex)
            {
                if (ex is ScriptCompilationException scriptEx)
                {
                    IsCompilationSuccessful = false;

                    if (scriptEx.CompilationOutput.Any())
                    {
                        CompilationOutput = CompilationOutput.Concat(scriptEx.CompilationOutput);
                    }

                    return;
                }

                throw;
            }
        }
        /// <summary>
        /// Initializes the entry point by compiling the script and loading/saving the assembly
        /// </summary>
        /// <returns>Taks for initializing entry point.</returns>
        public async Task InitializeEntryPointAsync()
        {
            var referenceResolver = new MemoryReferenceResolver(_frameworkLoads);
            ICompilationService compilationService = CompilationServiceFactory.CreateService(_entityMetaData, GetScriptOptions(referenceResolver));

            _compilation = await compilationService.GetCompilationAsync();

            _diagnostics = await _compilation.GetDiagnosticsAsync();

            References = referenceResolver.Used.ToImmutableArray();

            IsCompilationSuccessful = !_diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error);
            CompilationOutput       = _diagnostics.Select(m => m.ToString());

            if (IsCompilationSuccessful)
            {
                try
                {
                    memberInfo = await _compilation.GetEntryPoint();

                    InitializeAttributes();
                    Validate();
                }
                catch (Exception ex)
                {
                    if (ex is ScriptCompilationException scriptEx)
                    {
                        IsCompilationSuccessful = false;

                        if (scriptEx.CompilationOutput.Any())
                        {
                            CompilationOutput = CompilationOutput.Concat(scriptEx.CompilationOutput);
                        }

                        return;
                    }

                    throw;
                }
            }
        }