Ejemplo n.º 1
0
    private CefApiDeclarations BuildTypes()
    {
        var structs = new List <CefStructType>();
        var enums   = new List <CefEnumType>();
        var stringCollectionTypes = new List <StringCollectionType>();
        List <CefExportFunction> stringCollectionFunctions = new List <CefExportFunction>();
        List <CefExportFunction> functions = new List <CefExportFunction>();

        apiTypes = new SortedDictionary <string, ApiType>();

        AddType(new ApiType("void"));

        AddType(new CefBaseType());
        AddType(new CefBasePtrType());

        AddType(new CefColorType());
        AddType(new CefColorRefType());

        AddType(new BooleanInteger());
        AddType(new BooleanIntegerOutType());

        AddType(new OpaquePtrType("XDisplay"));
        AddType(new CefPlatformBasePtrType("cef_window_info_t*"));
        AddType(new CefPlatformBasePtrType("cef_main_args_t*"));

        AddType(new CefStringType());
        AddType(new CefStringPtrType());
        AddType(new CefStringUserFreeType());

        NumericType.CreateAll(this);

        var bTypes = AssemblyResources.GetLines("BlittableTypes.txt");

        foreach (var bt in bTypes)
        {
            var def = bt.Split('|');
            if (def.Length == 2 && def[0].Length > 0 && def[1].Length > 0)
            {
                AddType(new BlittableType(def[0], def[1]));
            }
        }

        AddType(new VoidPtrPtrType());

        foreach (var ed in apiData.CefEnums)
        {
            var t = new CefEnumType(ed);
            AddType(t);
            enums.Add(t);
        }

        foreach (var sd in apiData.CefStructs)
        {
            if (!apiTypes.Keys.Contains(sd.Name))
            {
                var structName = sd.Name.Substring(0, sd.Name.Length - 2);
                var t          = new CefStructType(structName, sd.Comments);
                AddType(t);
                structs.Add(t);
            }
        }

        foreach (var sd in apiData.CefStructsWindows)
        {
            var structName = sd.Name.Substring(0, sd.Name.Length - 2);
            var t          = new CefPlatformStructType(structName, sd.Comments, CefPlatform.Windows);
            AddType(t);
            structs.Add(t);
        }

        foreach (var sd in apiData.CefStructsLinux)
        {
            var structName = sd.Name.Substring(0, sd.Name.Length - 2);
            var t          = new CefPlatformStructType(structName, sd.Comments, CefPlatform.Linux);
            AddType(t);
            structs.Add(t);
        }

        stringCollectionTypes.Add(new CefStringListType());
        stringCollectionTypes.Add(new CefStringMapType());
        stringCollectionTypes.Add(new CefStringMultimapType());

        foreach (var t in stringCollectionTypes)
        {
            AddType(t);
        }

        foreach (var sd in apiData.CefStructs)
        {
            var t = apiTypes[sd.Name];
            if (t.IsCefStructType)
            {
                t.AsCefStructType.SetMembers(sd, this);
            }
        }

        foreach (var sd in apiData.CefStructsWindows)
        {
            var t = apiTypes[sd.Name.Substring(0, sd.Name.Length - 2) + "_windows"];
            t.AsCefStructType.SetMembers(sd, this);
        }

        foreach (var sd in apiData.CefStructsLinux)
        {
            var t = apiTypes[sd.Name.Substring(0, sd.Name.Length - 2) + "_linux"];
            t.AsCefStructType.SetMembers(sd, this);
        }

        foreach (var fd in apiData.CefStringCollectionFunctions)
        {
            stringCollectionFunctions.Add(new CefExportFunction(null, fd, this));
        }

        foreach (var fd in apiData.CefFunctions)
        {
            var f = new CefExportFunction(null, fd, this);
            functions.Add(f);
        }

        if (apiData.CefFunctionsWindows.Count > 0)
        {
            System.Diagnostics.Debugger.Break();
        }

        foreach (var fd in apiData.CefFunctionsLinux)
        {
            var f = new CefExportFunction(null, fd, this, CefPlatform.Linux);
            functions.Add(f);
        }

        functions.Sort(new CefExportFunction.Comparer());
        structs.Sort(new ApiType.Comparer());
        enums.Sort(new ApiType.Comparer());

        var decl = new CefApiDeclarations(functions.ToArray(), structs.ToArray(), enums.ToArray(), stringCollectionTypes.ToArray(), stringCollectionFunctions.ToArray());

        return(decl);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves the contents of the named resource string.
        /// </summary>
        /// <param name="resourceName">Resource string name.</param>
        /// <returns>Resource string contents.</returns>
        internal static string GetResourceString(string resourceName)
        {
            string result = AssemblyResources.GetString(resourceName);

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read everything from the assembly in a single stream.
        /// </summary>
        /// <returns></returns>
        private void CorePopulateMetadata()
        {
            if (_metadataRead)
            {
                return;
            }

            lock (this)
            {
                if (_metadataRead)
                {
                    return;
                }

                using (var stream = File.OpenRead(_sourceFile))
                    using (var peFile = new PEReader(stream))
                    {
                        bool hasMetadata = false;
                        try
                        {
                            // This can throw if the stream is too small, which means
                            // the assembly doesn't have metadata.
                            hasMetadata = peFile.HasMetadata;
                        }
                        finally
                        {
                            // If the file does not contain PE metadata, throw BadImageFormatException to preserve
                            // behavior from AssemblyName.GetAssemblyName(). RAR will deal with this correctly.
                            if (!hasMetadata)
                            {
                                throw new BadImageFormatException(string.Format(CultureInfo.CurrentCulture,
                                                                                AssemblyResources.GetString("ResolveAssemblyReference.AssemblyDoesNotContainPEMetadata"),
                                                                                _sourceFile));
                            }
                        }

                        var metadataReader = peFile.GetMetadataReader();

                        var assemblyReferences = metadataReader.AssemblyReferences;

                        List <AssemblyNameExtension> ret = new List <AssemblyNameExtension>(assemblyReferences.Count);

                        foreach (var handle in assemblyReferences)
                        {
                            var assemblyName = GetAssemblyName(metadataReader, handle);
                            ret.Add(new AssemblyNameExtension(assemblyName));
                        }

                        _assemblyDependencies = ret.ToArray();

                        foreach (var attrHandle in metadataReader.GetAssemblyDefinition().GetCustomAttributes())
                        {
                            var attr = metadataReader.GetCustomAttribute(attrHandle);

                            var ctorHandle = attr.Constructor;
                            if (ctorHandle.Kind != HandleKind.MemberReference)
                            {
                                continue;
                            }

                            var container = metadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent;
                            var name      = metadataReader.GetTypeReference((TypeReferenceHandle)container).Name;
                            if (!string.Equals(metadataReader.GetString(name), "TargetFrameworkAttribute"))
                            {
                                continue;
                            }

                            var arguments = GetFixedStringArguments(metadataReader, attr);
                            if (arguments.Count == 1)
                            {
                                _frameworkName = new FrameworkName(arguments[0]);
                            }
                        }

                        var assemblyFilesCollection = metadataReader.AssemblyFiles;

                        List <string> assemblyFiles = new List <string>(assemblyFilesCollection.Count);

                        foreach (var fileHandle in assemblyFilesCollection)
                        {
                            assemblyFiles.Add(metadataReader.GetString(metadataReader.GetAssemblyFile(fileHandle).Name));
                        }

                        _assemblyFiles = assemblyFiles.ToArray();
                    }

                _metadataRead = true;
            }
        }
Ejemplo n.º 4
0
        public void ExistsPromotedDependencyInTheBlackList()
        {
            string implicitRedistListContents =
                "<FileList Redist='Microsoft-Windows-CLRCoreComp' >" +
                "<File AssemblyName='UniFYme' Version='2.0.0.0' Culture='neutral' PublicKeyToken='b77a5c561934e089' InGAC='false' />" +
                "</FileList >";

            string engineOnlySubset =
                "<FileList Redist='Microsoft-Windows-CLRCoreComp' >" +
                "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                "</FileList >";

            string redistListPath = FileUtilities.GetTemporaryFile();
            string subsetListPath = FileUtilities.GetTemporaryFile();
            string appConfigFile  = null;

            try
            {
                File.WriteAllText(redistListPath, implicitRedistListContents);
                File.WriteAllText(subsetListPath, engineOnlySubset);


                // Create the engine.
                MockEngine engine = new MockEngine();

                ITaskItem[] assemblyNames = new TaskItem[]
                {
                    new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
                };

                // Construct the app.config.
                appConfigFile = WriteAppConfig
                                (
                    "        <dependentAssembly>\n" +
                    "            <assemblyIdentity name='UnifyMe' PublicKeyToken='b77a5c561934e089' culture='neutral' />\n" +
                    "            <bindingRedirect oldVersion='1.0.0.0' newVersion='2.0.0.0' />\n" +
                    "        </dependentAssembly>\n"
                                );

                // Now, pass feed resolved primary references into ResolveAssemblyReference.
                ResolveAssemblyReference t = new ResolveAssemblyReference();
                t.InstalledAssemblyTables       = new TaskItem[] { new TaskItem(redistListPath) };
                t.InstalledAssemblySubsetTables = new TaskItem[] { new TaskItem(subsetListPath) };

                t.BuildEngine   = engine;
                t.Assemblies    = assemblyNames;
                t.SearchPaths   = DefaultPaths;
                t.AppConfigFile = appConfigFile;

                bool succeeded = Execute(t);

                Assert.True(succeeded);
                Assert.Equal(0, t.ResolvedDependencyFiles.Length);
                engine.AssertLogDoesntContain
                (
                    String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAppConfig"), "1.0.0.0", appConfigFile, Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"))
                );
            }
            finally
            {
                File.Delete(redistListPath);
                File.Delete(subsetListPath);

                // Cleanup.
                File.Delete(appConfigFile);
            }
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------------
        // Validate the essence alias between two given facts.
        //-------------------------------------------------------------------------------
        private void ValidateEssenceAliasedFacts(Item FromItem, Item ToItem)
        {
            // Essence alias checks for c-equals items are a bit tricky, according to the
            // XBRL-CONF-CR3-2007-03-05 conformance suite. Test 392.11 says that it is valid
            // to have two items with contexts having the same structure but different
            // period values is valid; however, test 392.13 says that it is invalid two have
            // two items with contexts having a different structure.

            if (FromItem.ContextEquals(ToItem) == false)
            {
                if ((FromItem.ContextRef != null) && (ToItem.ContextRef != null))
                {
                    if (FromItem.ContextRef.PeriodTypeEquals(ToItem.ContextRef) == false)
                    {
                        StringBuilder MessageBuilder = new StringBuilder();
                        string        StringFormat   = AssemblyResources.GetName("EssenceAliasFactsNotContextEquals");
                        MessageBuilder.AppendFormat(StringFormat, FromItem.Name, ToItem.Name, FromItem.Id, ToItem.Id);
                        var validationError = new ItemsValidationError(MessageBuilder.ToString());
                        validationError.AddItem(FromItem);
                        validationError.AddItem(ToItem);
                        validatingFragment.AddValidationError(validationError);
                        return;
                    }
                }
                return;
            }
            if (FromItem.ParentEquals(ToItem) == false)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("EssenceAliasFactsNotParentEquals");
                MessageBuilder.AppendFormat(StringFormat, FromItem.Name, ToItem.Name, FromItem.Id, ToItem.Id);
                var validationError = new ItemsValidationError(MessageBuilder.ToString());
                validationError.AddItem(FromItem);
                validationError.AddItem(ToItem);
                validatingFragment.AddValidationError(validationError);
                return;
            }
            if (FromItem.UnitEquals(ToItem) == false)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("EssenceAliasFactsNotUnitEquals");
                MessageBuilder.AppendFormat(StringFormat, FromItem.Name, ToItem.Name, FromItem.Id, ToItem.Id);
                var validationError = new ItemsValidationError(MessageBuilder.ToString());
                validationError.AddItem(FromItem);
                validationError.AddItem(ToItem);
                validatingFragment.AddValidationError(validationError);
                return;
            }

            // At this point, the valies of the items need to be compared. Check the item's type
            // to ensure that the correct value is being compared.

            var ItemValuesMatch = true;

            if (FromItem.SchemaElement.TypeName.Name.Equals("stringItemType") == true)
            {
                ItemValuesMatch = FromItem.Value.Equals(ToItem.Value);
            }
            else
            {
                if (FromItem.RoundedValue != ToItem.RoundedValue)
                {
                    ItemValuesMatch = false;
                }
            }
            if (ItemValuesMatch == false)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("EssenceAliasFactsHaveDifferentRoundedValues");
                MessageBuilder.AppendFormat(StringFormat, FromItem.Name, ToItem.Name, FromItem.Id, FromItem.RoundedValue.ToString(), ToItem.Id, ToItem.RoundedValue.ToString());
                var validationError = new ItemsValidationError(MessageBuilder.ToString());
                validationError.AddItem(FromItem);
                validationError.AddItem(ToItem);
                validatingFragment.AddValidationError(validationError);
                return;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Validates a given summation concept.
        /// </summary>
        /// <param name="CurrentCalculationLink">
        /// The calculation link that defines the given summation concept.
        /// </param>
        /// <param name="CurrentSummationConcept">
        /// The summation concept to be validated.
        /// </param>
        /// <param name="FactList">
        /// The collection of items that should be searched when looking for summation or contributing items.
        /// </param>
        private void ValidateSummationConcept(CalculationLink CurrentCalculationLink, SummationConcept CurrentSummationConcept, FactCollection FactList)
        {
            Element SummationConceptElement = LocateElement(CurrentSummationConcept.SummationConceptLocator);
            Item    SummationConceptItem    = LocateItem(SummationConceptElement, FactList);

            // If the summation concept item doesn't exist, then there is no calculation
            // to perform.

            if (SummationConceptItem == null)
            {
                return;
            }

            // If the summation concept item has a "nil" value, then there is no calculation
            // to perform.

            if (SummationConceptItem.NilSpecified == true)
            {
                return;
            }

            double SummationConceptRoundedValue         = SummationConceptItem.RoundedValue;
            double ContributingConceptRoundedValueTotal = 0;
            var    ContributingConceptItemsFound        = false;
            var    AtLeastOneItemWithZeroPrecision      = false;

            foreach (Locator CurrentLocator in CurrentSummationConcept.ContributingConceptLocators)
            {
                // Some decisions need to be made before the code can actually add the value of the
                // contributing concept to the total that the code is keeping.

                var IncludeContributingConceptItemInCalculation = true;

                // Find the calculation arc for the given calculation link.

                CalculationArc ContributingConceptCalculationArc = CurrentCalculationLink.GetCalculationArc(CurrentLocator);
                if (ContributingConceptCalculationArc == null)
                {
                    IncludeContributingConceptItemInCalculation = false;
                }

                // Find the elemement for the given locator.

                Element ContributingConceptElement = LocateElement(CurrentLocator);
                if (ContributingConceptElement == null)
                {
                    IncludeContributingConceptItemInCalculation = false;
                }

                // Find all items for the given element. If there is more than one, and at least
                // one of them is not p-equals with at least one of the other ones, then
                // the entire calculation validation is forfeit, according to test 397.12 in
                // the XBRL-CONF-CR3-2007-03-05 conformance suite.

                var AllMatchingItems = LocateItems(ContributingConceptElement, FactList);
                if (AllItemsNotPEquals(AllMatchingItems) == false)
                {
                    return;
                }

                // Find the item for the given element.

                if (AllMatchingItems.Count == 0)
                {
                    IncludeContributingConceptItemInCalculation = false;
                }
                else
                {
                    foreach (var ContributingConceptItem in AllMatchingItems)
                    {
                        if (IncludeContributingConceptItemInCalculation == true)
                        {
                            IncludeContributingConceptItemInCalculation = ContributingConceptItemEligibleForUseInCalculation(ContributingConceptItem, SummationConceptItem);
                        }
                        if (IncludeContributingConceptItemInCalculation == true)
                        {
                            ContributingConceptItemsFound = true;
                            if ((ContributingConceptItem.PrecisionSpecified == true) && (ContributingConceptItem.Precision == 0) && (ContributingConceptItem.InfinitePrecision == false))
                            {
                                AtLeastOneItemWithZeroPrecision = true;
                            }
                            double ContributingConceptRoundedValue = ContributingConceptItem.RoundedValue;
                            if (ContributingConceptCalculationArc.Weight != (decimal)(1.0))
                            {
                                ContributingConceptRoundedValue = ContributingConceptRoundedValue * (double)(ContributingConceptCalculationArc.Weight);
                            }
                            ContributingConceptRoundedValueTotal += ContributingConceptRoundedValue;
                        }
                    }
                }
            }
            if (ContributingConceptItemsFound == true)
            {
                if (AtLeastOneItemWithZeroPrecision == true)
                {
                    var    MessageBuilder = new StringBuilder();
                    string StringFormat   = AssemblyResources.GetName("SummationConceptUsesContributingItemWithPrecisionZero");
                    MessageBuilder.AppendFormat(StringFormat, SummationConceptItem.Name);
                    ValidatedFragment.AddValidationError(new SummationConceptValidationError(CurrentSummationConcept, MessageBuilder.ToString()));
                    return;
                }
                ContributingConceptRoundedValueTotal = SummationConceptItem.Round(ContributingConceptRoundedValueTotal);
                if (SummationConceptRoundedValue != ContributingConceptRoundedValueTotal)
                {
                    var    MessageBuilder = new StringBuilder();
                    string StringFormat   = AssemblyResources.GetName("SummationConceptError");
                    MessageBuilder.AppendFormat(StringFormat, SummationConceptItem.Name, SummationConceptRoundedValue, ContributingConceptRoundedValueTotal);
                    ValidatedFragment.AddValidationError(new SummationConceptValidationError(CurrentSummationConcept, MessageBuilder.ToString()));
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        public void ExistsWithPrimaryReferenceOnBlackList()
        {
            string implicitRedistListContents =
                "<FileList Redist='Microsoft-Windows-CLRCoreComp' >" +
                "<File AssemblyName='DependsOnUnified' Version='2.0.0.0' Culture='neutral' PublicKeyToken='b77a5c561934e089' InGAC='false' />" +
                "</FileList >";

            string engineOnlySubset =
                "<FileList Redist='Microsoft-Windows-CLRCoreComp' >" +
                "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                "</FileList >";

            string redistListPath = FileUtilities.GetTemporaryFile();
            string subsetListPath = FileUtilities.GetTemporaryFile();

            try
            {
                File.WriteAllText(redistListPath, implicitRedistListContents);
                File.WriteAllText(subsetListPath, engineOnlySubset);


                // Create the engine.
                MockEngine engine = new MockEngine();

                ITaskItem[] assemblyNames = new TaskItem[]
                {
                    new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
                    new TaskItem("DependsOnUnified, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
                };

                // Now, pass feed resolved primary references into ResolveAssemblyReference.
                ResolveAssemblyReference t = new ResolveAssemblyReference();

                t.InstalledAssemblyTables       = new TaskItem[] { new TaskItem(redistListPath) };
                t.InstalledAssemblySubsetTables = new TaskItem[] { new TaskItem(subsetListPath) };
                t.BuildEngine = engine;
                t.Assemblies  = assemblyNames;
                t.SearchPaths = DefaultPaths;
                t.AutoUnify   = true;

                bool succeeded = Execute(t);

                Assert.True(succeeded);
                Assert.Equal(1, t.ResolvedFiles.Length);                                                                  // "Expected there to only be one resolved file"
                Assert.True(t.ResolvedFiles[0].ItemSpec.Contains(Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"))); // "Expected the ItemSpec of the resolved file to be the item spec of the 1.0.0.0 assembly");
                Assert.Equal(1, t.ResolvedDependencyFiles.Length);                                                        // "Expected there to be two resolved dependencies"
                AssertNoCase("UnifyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", t.ResolvedDependencyFiles[0].GetMetadata("FusionName"));
                AssertNoCase(s_unifyMeDll_V10Path, t.ResolvedDependencyFiles[0].ItemSpec);

                engine.AssertLogDoesntContain
                (
                    String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnifiedDependency"), "UnifyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=MSIL")
                );

                engine.AssertLogDoesntContain
                (
                    String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAutoUnify"), "1.0.0.0", Path.Combine(s_myApp_V20Path, "DependsOnUnified.dll"))
                );
            }
            finally
            {
                File.Delete(redistListPath);
                File.Delete(subsetListPath);
            }
        }
Ejemplo n.º 8
0
        public void HighVersionDoesntExist()
        {
            // Create the engine.
            MockEngine engine = new MockEngine(_output);

            ITaskItem[] assemblyNames = new TaskItem[]
            {
                new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
            };

            // Construct the app.config.
            string appConfigFile = WriteAppConfig
                                   (
                "        <dependentAssembly>\n" +
                "            <assemblyIdentity name='UnifyMe' PublicKeyToken='b77a5c561934e089' culture='neutral' />\n" +
                "            <bindingRedirect oldVersion='1.0.0.0' newVersion='4.0.0.0' />\n" +
                "        </dependentAssembly>\n"
                                   );

            // Now, pass feed resolved primary references into ResolveAssemblyReference.
            ResolveAssemblyReference t = new ResolveAssemblyReference();

            t.BuildEngine   = engine;
            t.Assemblies    = assemblyNames;
            t.SearchPaths   = DefaultPaths;
            t.AppConfigFile = appConfigFile;

            bool succeeded = Execute(t);

            Assert.True(succeeded);
            Assert.Empty(t.ResolvedDependencyFiles);
            string shouldContain;

            string code = t.Log.ExtractMessageCode
                          (
                String.Format(AssemblyResources.GetString("ResolveAssemblyReference.FailedToResolveReference"),
                              String.Format(AssemblyResources.GetString("General.CouldNotLocateAssembly"), "UNIFyMe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")),
                out shouldContain
                          );


            engine.AssertLogContains
            (
                shouldContain
            );

            engine.AssertLogContains
            (
                String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAppConfig"), "1.0.0.0", appConfigFile, Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"))
            );

            engine.AssertLogContains
            (
                String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnifiedDependency"), "UNIFyMe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
            );



            // Cleanup.
            File.Delete(appConfigFile);
        }
Ejemplo n.º 9
0
        public void MultipleUnifiedFromNamesMiddlePrimaryOnBlackList()
        {
            string implicitRedistListContents =
                "<FileList Redist='Microsoft-Windows-CLRCoreComp' >" +
                "<File AssemblyName='DependsOnUnified' Version='3.0.0.0' Culture='neutral' PublicKeyToken='b77a5c561934e089' InGAC='false' />" +
                "</FileList >";

            string engineOnlySubset =
                "<FileList Redist='Microsoft-Windows-CLRCoreComp' >" +
                "<File AssemblyName='Microsoft.Build.Engine' Version='2.0.0.0' PublicKeyToken='b03f5f7f11d50a3a' Culture='Neutral' FileVersion='2.0.50727.208' InGAC='true' />" +
                "</FileList >";

            string redistListPath = FileUtilities.GetTemporaryFile();
            string subsetListPath = FileUtilities.GetTemporaryFile();

            File.WriteAllText(redistListPath, implicitRedistListContents);
            File.WriteAllText(subsetListPath, engineOnlySubset);

            // Create the engine.
            MockEngine engine = new MockEngine(_output);

            ITaskItem[] assemblyNames = new TaskItem[]
            {
                new TaskItem("DependsOnUnified, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
                new TaskItem("DependsOnUnified, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
                new TaskItem("DependsOnUnified, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
            };

            // Now, pass feed resolved primary references into ResolveAssemblyReference.
            ResolveAssemblyReference t = new ResolveAssemblyReference();

            t.InstalledAssemblyTables       = new TaskItem[] { new TaskItem(redistListPath) };
            t.InstalledAssemblySubsetTables = new TaskItem[] { new TaskItem(subsetListPath) };

            t.BuildEngine = engine;
            t.Assemblies  = assemblyNames;
            t.SearchPaths = DefaultPaths;
            t.TargetFrameworkDirectories = new string[] { @"c:\myfx" };
            t.AutoUnify = true;

            bool succeeded = Execute(t);

            Assert.True(succeeded);
            Assert.Equal(2, t.ResolvedFiles.Length);                                                           // "Expected to find two resolved assemblies"
            Assert.True(ContainsItem(t.ResolvedFiles, Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"))); // "Expected the ItemSpec of the resolved file to be the item spec of the 1.0.0.0 assembly");
            Assert.True(ContainsItem(t.ResolvedFiles, Path.Combine(s_myApp_V20Path, "DependsOnUnified.dll"))); // "Expected the ItemSpec of the resolved file to be the item spec of the 2.0.0.0 assembly");
            t.ResolvedDependencyFiles[0].GetMetadata("FusionName").ShouldBe("UnifyMe, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", StringCompareShould.IgnoreCase);
            t.ResolvedDependencyFiles[0].ItemSpec.ShouldBe(s_unifyMeDll_V20Path, StringCompareShould.IgnoreCase);

            engine.AssertLogContains
            (
                String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnifiedDependency"), "UniFYme, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
            );

            engine.AssertLogContains
            (
                String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAutoUnify"), "1.0.0.0", Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"))
            );

            engine.AssertLogDoesntContain
            (
                String.Format(AssemblyResources.GetString("ResolveAssemblyReference.UnificationByAutoUnify"), "2.0.0.0", Path.Combine(s_myApp_V20Path, "DependsOnUnified.dll"))
            );
        }
Ejemplo n.º 10
0
 protected override System.Xml.Xsl.XslCompiledTransform GetXsltStylesheet()
 {
     return(AssemblyResources.GetXsltStylesheet("AmplaTools.ProjectCreate.Resources.Stylesheets.B2MMLStylesheet.xslt"));
 }
Ejemplo n.º 11
0
        [PlatformSpecific(Xunit.PlatformID.Windows)] // "Under Unix all filenames are valid and this test is not useful"
        public void SomeInputsFailToCreate()
        {
            string temp    = Path.GetTempPath();
            string file    = Path.Combine(temp, "2A333ED756AF4dc392E728D0F864A38e");
            string dir     = Path.Combine(temp, "2A333ED756AF4dc392E728D0F864A38f");
            string invalid = "!@#$%^&*()|";
            string dir2    = Path.Combine(temp, "2A333ED756AF4dc392E728D0F864A390");

            try
            {
                FileStream fs = File.Create(file);
                fs.Dispose(); //we're gonna try to delete it

                MakeDir    t      = new MakeDir();
                MockEngine engine = new MockEngine();
                t.BuildEngine = engine;

                t.Directories = new ITaskItem[]
                {
                    new TaskItem(dir),
                    new TaskItem(file),
                    new TaskItem(invalid),
                    new TaskItem(dir2)
                };

                bool success = t.Execute();

                if (NativeMethodsShared.IsWindows)
                {
                    Assert.False(success);
                    Assert.Equal(2, t.DirectoriesCreated.Length);
                    Assert.Equal(dir2, t.DirectoriesCreated[1].ItemSpec);
                }
                else
                {
                    // Since Unix pretty much does not have invalid characters,
                    // the invalid name is not really invalid
                    Assert.True(success);
                    Assert.Equal(3, t.DirectoriesCreated.Length);
                    Assert.Equal(dir2, t.DirectoriesCreated[2].ItemSpec);
                }

                Assert.Equal(dir, t.DirectoriesCreated[0].ItemSpec);
                Assert.True
                (
                    engine.Log.Contains
                    (
                        String.Format(AssemblyResources.GetString("MakeDir.Comment"), dir)
                    )
                );
            }
            finally
            {
                FileUtilities.DeleteWithoutTrailingBackslash(dir);
                File.Delete(file);
                if (!NativeMethodsShared.IsWindows)
                {
                    File.Delete(invalid);
                }
                FileUtilities.DeleteWithoutTrailingBackslash(dir2);
            }
        }