예제 #1
0
 public AssemblyLoadRequest(
     EvaluationContextId evaluationContextId,
     AssemblyDefinition [] assemblies)
 {
     EvaluationContextId = evaluationContextId;
     Assemblies          = assemblies;
 }
예제 #2
0
 public Compilation(
     CodeCellId codeCellId,
     int submissionNumber,
     EvaluationContextId evaluationContextId,
     EvaluationEnvironment evaluationEnvironment,
     bool isResultAnExpression,
     AssemblyDefinition executableAssembly,
     IReadOnlyList <AssemblyDefinition> references)
 {
     CodeCellId            = codeCellId;
     SubmissionNumber      = submissionNumber;
     EvaluationContextId   = evaluationContextId;
     EvaluationEnvironment = evaluationEnvironment;
     IsResultAnExpression  = isResultAnExpression;
     ExecutableAssembly    = executableAssembly;
     References            = references;
 }
예제 #3
0
        internal static async Task LoadFormsAgentExtensions(
            Version formsVersion,
            IAgentConnection agent,
            DependencyResolver dependencyResolver,
            EvaluationContextId evaluationContextId,
            bool includePeImage)
        {
            var formsAssembly = InteractiveInstallation.Default.LocateFormsAssembly(agent.Type);

            if (string.IsNullOrWhiteSpace(formsAssembly))
            {
                return;
            }

            var deps = dependencyResolver.Resolve(new [] { new FilePath(formsAssembly) });

            // Now dig out the resolved assembly that is Xamarin.Forms.Core, and compare it to the
            // default ref.
            var resolvedFormsAssembly = deps.FirstOrDefault(d => d.AssemblyName.Name == "Xamarin.Forms.Core");

            if (resolvedFormsAssembly == null)
            {
                Log.Warning(TAG,
                            "Cannot enable Forms integration because Forms cannot be " +
                            "resolved. Check log for assembly search path issues.");
                return;
            }
            var ourVersion   = resolvedFormsAssembly.AssemblyName.Version;
            var theirVersion = formsVersion;

            if (ourVersion.Major != theirVersion.Major)
            {
                Log.Warning(
                    TAG,
                    "Assembly version mismatch between app's Xamarin.Forms.Core and" +
                    $"our referenced Xamarin.Forms.Core. Our version: {ourVersion}, " +
                    $"their version: {theirVersion}. Won't load Xamarin.Forms agent " +
                    "integration, as it probably won't work."
                    );
                return;
            }

            var assembliesToLoad = deps.Select(dep => {
                var peImage = includePeImage ? GetFileBytes(dep.Path) : null;
                var syms    = includePeImage ? GetDebugSymbolsFromAssemblyPath(dep.Path) : null;
                return(new AssemblyDefinition(
                           dep.AssemblyName,
                           dep.Path,
                           peImage: peImage,
                           debugSymbols: syms
                           ));
            }).ToArray();

            var res = await agent.Api.LoadAssembliesAsync(
                evaluationContextId,
                assembliesToLoad);

            var failed = res.LoadResults.Where(p => !p.Success);

            if (failed.Any())
            {
                var failedLoads = string.Join(", ", failed.Select(p => p.AssemblyName.Name));
                Log.Warning(
                    TAG,
                    $"Xamarin.Forms reference detected, but integration may not have" +
                    $" loaded properly. Assemblies that did not load: {failedLoads}");
            }
        }