Example #1
0
            public bool Verify(string asmName, string typeName, string baselineFile, bool pdb)
            {
                try
                {
                    var      xslt    = new XslCompiledTransform();
                    Assembly xsltasm = AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.GetFullPath(asmName));

                    if (xsltasm == null)
                    {
                        //_output.WriteLine("Could not load file");
                        return(false);
                    }

                    Type t = xsltasm.GetType(typeName);

                    if (t == null)
                    {
                        //_output.WriteLine("No type loaded");
                        return(false);
                    }

                    xslt.Load(t);

                    var inputXml = new XmlDocument();

                    using (var stream = new MemoryStream())
                        using (var sw = new StreamWriter(stream)
                        {
                            AutoFlush = true
                        })
                        {
                            inputXml.LoadXml("<foo><bar>Hello, world!</bar></foo>");
                            xslt.Transform(inputXml, null, sw);

                            if (!XsltVerificationLibrary.CompareXml(Path.Combine(XsltcModule.TargetDirectory, baselineFile), stream))
                            {
                                //_output.WriteLine("Baseline file comparison failed");
                                return(false);
                            }
                        }

                    return(true);
                }
                catch (Exception e)
                {
                    s_output.WriteLine(e.Message);
                    return(false);
                }
                // Turning this off as this causes noise on different platforms like IA64.
                // Also since we verify the assembly by loading there is not really a need for this verification.
                // if (succeeded && runAssemblyVerification) {
                //    String peOutput = String.Empty;
                //    succeeded = XsltVerificationLibrary.VerifyAssemblyUsingPEVerify(
                //            asmName,
                //            logger,
                //            ref peOutput);
                //    logger.LogMessage("Assembly Verification Result: " + peOutput);
                //}
            }
            public bool Verify(string asmName, string typeName, string baselineFile, bool pdb)
            {
                try
                {
                    var      xslt    = new XslCompiledTransform();
                    Assembly xsltasm = AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.GetFullPath(asmName));

                    if (xsltasm == null)
                    {
                        //_output.WriteLine("Could not load file");
                        return(false);
                    }

                    Type t = xsltasm.GetType(typeName);

                    if (t == null)
                    {
                        //_output.WriteLine("No type loaded");
                        return(false);
                    }

                    xslt.Load(t);

                    var inputXml = new XmlDocument();

                    using (var stream = new MemoryStream())
                        using (var sw = new StreamWriter(stream)
                        {
                            AutoFlush = true
                        })
                        {
                            inputXml.LoadXml("<foo><bar>Hello, world!</bar></foo>");
                            xslt.Transform(inputXml, null, sw);

                            if (!XsltVerificationLibrary.CompareXml(Path.Combine(XsltcModule.TargetDirectory, baselineFile), stream))
                            {
                                //_output.WriteLine("Baseline file comparison failed");
                                return(false);
                            }
                        }

                    return(true);
                }
                catch (Exception e)
                {
                    s_output.WriteLine(e.Message);
                    return(false);
                }
            }