예제 #1
0
        public virtual TestCaseLinkerOptions GetLinkerOptions()
        {
            var tclo = new TestCaseLinkerOptions {
                Il8n = GetOptionAttributeValue(nameof(Il8nAttribute), "none"),
                IncludeBlacklistStep            = GetOptionAttributeValue(nameof(IncludeBlacklistStepAttribute), false),
                KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue(nameof(KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
                KeepDebugMembers     = GetOptionAttributeValue(nameof(SetupLinkerKeepDebugMembersAttribute), string.Empty),
                LinkSymbols          = GetOptionAttributeValue(nameof(SetupLinkerLinkSymbolsAttribute), string.Empty),
                CoreAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerCoreActionAttribute), null),
                UserAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerUserActionAttribute), null),
                SkipUnresolved       = GetOptionAttributeValue(nameof(SkipUnresolvedAttribute), false),
                StripResources       = GetOptionAttributeValue(nameof(StripResourcesAttribute), true)
            };

            foreach (var assemblyAction in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerActionAttribute)))
            {
                var ca = assemblyAction.ConstructorArguments;
                tclo.AssembliesAction.Add(new KeyValuePair <string, string> ((string)ca [0].Value, (string)ca [1].Value));
            }

            foreach (var additionalArgumentAttr in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerArgumentAttribute)))
            {
                var ca     = additionalArgumentAttr.ConstructorArguments;
                var values = ((CustomAttributeArgument [])ca [1].Value)?.Select(arg => arg.Value.ToString()).ToArray();
                tclo.AdditionalArguments.Add(new KeyValuePair <string, string []> ((string)ca [0].Value, values));
            }

            return(tclo);
        }
예제 #2
0
        public virtual void ProcessOptions(TestCaseLinkerOptions options)
        {
            if (options.CoreAssembliesAction != null)
            {
                AddCoreLink(options.CoreAssembliesAction);
            }

            if (options.AssembliesAction != null)
            {
                foreach (var entry in options.AssembliesAction)
                {
                    AddAssemblyAction(entry.Key, entry.Value);
                }
            }

            // Running the blacklist step causes a ton of stuff to be preserved.  That's good for normal use cases, but for
            // our test cases that pollutes the results
            IncludeBlacklist(options.IncludeBlacklistStep);

            // Internationalization assemblies pollute our test case results as well so disable them
            if (!string.IsNullOrEmpty(options.Il8n))
            {
                AddIl8n(options.Il8n);
            }

            if (!string.IsNullOrEmpty(options.KeepTypeForwarderOnlyAssemblies))
            {
                AddKeepTypeForwarderOnlyAssemblies(options.KeepTypeForwarderOnlyAssemblies);
            }
        }
        public virtual void ProcessOptions(TestCaseLinkerOptions options)
        {
            if (options.CoreAssembliesAction != null)
            {
                AddCoreLink(options.CoreAssembliesAction);
            }

            if (options.UserAssembliesAction != null)
            {
                AddUserLink(options.UserAssembliesAction);
            }

            if (options.AssembliesAction != null)
            {
                foreach (var entry in options.AssembliesAction)
                {
                    AddAssemblyAction(entry.Key, entry.Value);
                }
            }

            // Running the blacklist step causes a ton of stuff to be preserved.  That's good for normal use cases, but for
            // our test cases that pollutes the results
            IncludeBlacklist(options.IncludeBlacklistStep);

            if (!string.IsNullOrEmpty(options.Il8n))
            {
                AddIl8n(options.Il8n);
            }

            if (!string.IsNullOrEmpty(options.KeepTypeForwarderOnlyAssemblies))
            {
                AddKeepTypeForwarderOnlyAssemblies(options.KeepTypeForwarderOnlyAssemblies);
            }

            if (!string.IsNullOrEmpty(options.LinkSymbols))
            {
                AddLinkSymbols(options.LinkSymbols);
            }

            if (!string.IsNullOrEmpty(options.KeepDebugMembers))
            {
                AddKeepDebugMembers(options.KeepDebugMembers);
            }

            AddSkipUnresolved(options.SkipUnresolved);

            AddStripResources(options.StripResources);

            foreach (var substitutions in options.Substitutions)
            {
                AddSubstitutions(substitutions);
            }

            // Unity uses different argument format and needs to be able to translate to their format.  In order to make that easier
            // we keep the information in flag + values format for as long as we can so that this information doesn't have to be parsed out of a single string
            foreach (var additionalArgument in options.AdditionalArguments)
            {
                AddAdditionalArgument(additionalArgument.Key, additionalArgument.Value);
            }
        }
예제 #4
0
        public virtual TestCaseLinkerOptions GetLinkerOptions(NPath inputPath)
        {
            var tclo = new TestCaseLinkerOptions {
                Il8n = GetOptionAttributeValue(nameof(Il8nAttribute), "none"),
                IncludeBlacklistStep            = GetOptionAttributeValue(nameof(IncludeBlacklistStepAttribute), false),
                KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue(nameof(KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
                KeepDebugMembers     = GetOptionAttributeValue(nameof(SetupLinkerKeepDebugMembersAttribute), string.Empty),
                LinkSymbols          = GetOptionAttributeValue(nameof(SetupLinkerLinkSymbolsAttribute), string.Empty),
                CoreAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerCoreActionAttribute), null),
                UserAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerUserActionAttribute), null),
                SkipUnresolved       = GetOptionAttributeValue(nameof(SkipUnresolvedAttribute), false),
                StripResources       = GetOptionAttributeValue(nameof(StripResourcesAttribute), true),
            };

            foreach (var assemblyAction in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerActionAttribute)))
            {
                var ca = assemblyAction.ConstructorArguments;
                tclo.AssembliesAction.Add(new KeyValuePair <string, string> ((string)ca [0].Value, (string)ca [1].Value));
            }

            foreach (var subsFile in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerSubstitutionFileAttribute)))
            {
                var ca   = subsFile.ConstructorArguments;
                var file = (string)ca [0].Value;
                tclo.Substitutions.Add(Path.Combine(inputPath, file));
            }

            foreach (var additionalArgumentAttr in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerArgumentAttribute)))
            {
                var ca     = additionalArgumentAttr.ConstructorArguments;
                var values = ((CustomAttributeArgument [])ca [1].Value)?.Select(arg => arg.Value.ToString()).ToArray();
                // Since custom attribute arguments need to be constant expressions, we need to add
                // the path to the temp directory (where the custom assembly is located) here.
                if ((string)ca [0].Value == "--custom-step")
                {
                    int pos = values [0].IndexOf(",");
                    if (pos != -1)
                    {
                        string custom_assembly_path = values [0].Substring(pos + 1);
                        if (!Path.IsPathRooted(custom_assembly_path))
                        {
                            values [0] = values [0].Substring(0, pos + 1) + Path.Combine(inputPath, custom_assembly_path);
                        }
                    }
                }
                tclo.AdditionalArguments.Add(new KeyValuePair <string, string []> ((string)ca [0].Value, values));
            }

            if (_testCaseTypeDefinition.CustomAttributes.Any(attr =>
                                                             attr.AttributeType.Name == nameof(LogContainsAttribute) || attr.AttributeType.Name == nameof(LogDoesNotContainAttribute)))
            {
                tclo.AdditionalArguments.Add(new KeyValuePair <string, string []> ("--verbose", new string [] { }));
            }

            return(tclo);
        }
예제 #5
0
        public virtual TestCaseLinkerOptions GetLinkerOptions()
        {
            var tclo = new TestCaseLinkerOptions {
                Il8n = GetOptionAttributeValue(nameof(Il8nAttribute), string.Empty),
                IncludeBlacklistStep            = GetOptionAttributeValue(nameof(IncludeBlacklistStepAttribute), false),
                KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue(nameof(KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
                CoreAssembliesAction            = GetOptionAttributeValue <string> (nameof(SetupLinkerCoreActionAttribute), null)
            };

            foreach (var assemblyAction in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerActionAttribute)))
            {
                var ca = assemblyAction.ConstructorArguments;
                tclo.AssembliesAction.Add(new KeyValuePair <string, string> ((string)ca [0].Value, (string)ca [1].Value));
            }

            return(tclo);
        }
예제 #6
0
        public virtual void ProcessOptions(TestCaseLinkerOptions options)
        {
            AddCoreLink(options.CoreLink);

            // Running the blacklist step causes a ton of stuff to be preserved.  That's good for normal use cases, but for
            // our test cases that pollutes the results
            if (!string.IsNullOrEmpty(options.IncludeBlacklistStep))
            {
                IncludeBlacklist(options.IncludeBlacklistStep);
            }

            // Internationalization assemblies pollute our test case results as well so disable them
            if (!string.IsNullOrEmpty(options.Il8n))
            {
                AddIl8n(options.Il8n);
            }
        }
예제 #7
0
        public virtual TestCaseLinkerOptions GetLinkerOptions(NPath inputPath)
        {
            var tclo = new TestCaseLinkerOptions {
                Il8n = GetOptionAttributeValue(nameof(Il8nAttribute), "none"),
                IncludeBlacklistStep            = GetOptionAttributeValue(nameof(IncludeBlacklistStepAttribute), false),
                KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue(nameof(KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
                KeepDebugMembers     = GetOptionAttributeValue(nameof(SetupLinkerKeepDebugMembersAttribute), string.Empty),
                LinkSymbols          = GetOptionAttributeValue(nameof(SetupLinkerLinkSymbolsAttribute), string.Empty),
                CoreAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerCoreActionAttribute), null),
                UserAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerUserActionAttribute), null),
                SkipUnresolved       = GetOptionAttributeValue(nameof(SkipUnresolvedAttribute), false),
                StripResources       = GetOptionAttributeValue(nameof(StripResourcesAttribute), true),
            };

            foreach (var assemblyAction in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerActionAttribute)))
            {
                var ca = assemblyAction.ConstructorArguments;
                tclo.AssembliesAction.Add(new KeyValuePair <string, string> ((string)ca [0].Value, (string)ca [1].Value));
            }

            foreach (var subsFile in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerSubstitutionFileAttribute)))
            {
                var ca   = subsFile.ConstructorArguments;
                var file = (string)ca [0].Value;
                tclo.Substitutions.Add(Path.Combine(inputPath, file));
            }

            foreach (var additionalArgumentAttr in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerArgumentAttribute)))
            {
                var ca     = additionalArgumentAttr.ConstructorArguments;
                var values = ((CustomAttributeArgument [])ca [1].Value)?.Select(arg => arg.Value.ToString()).ToArray();
                tclo.AdditionalArguments.Add(new KeyValuePair <string, string []> ((string)ca [0].Value, values));
            }

            if (_testCaseTypeDefinition.CustomAttributes.Any(attr =>
                                                             attr.AttributeType.Name == nameof(LogContainsAttribute) || attr.AttributeType.Name == nameof(LogDoesNotContainAttribute)))
            {
                tclo.AdditionalArguments.Add(new KeyValuePair <string, string []> ("--verbose", new string [] { }));
            }

            return(tclo);
        }
예제 #8
0
        public virtual void ProcessOptions(TestCaseLinkerOptions options)
        {
            if (options.CoreAssembliesAction != null)
            {
                AddCoreLink(options.CoreAssembliesAction);
            }
            else
            {
                AddCoreLink("skip");
            }

            if (options.UserAssembliesAction != null)
            {
                AddUserLink(options.UserAssembliesAction);
            }

            if (options.AssembliesAction != null)
            {
                foreach (var entry in options.AssembliesAction)
                {
                    AddAssemblyAction(entry.Key, entry.Value);
                }
            }

            // Honoring descriptors causes a ton of stuff to be preserved.  That's good for normal use cases, but for
            // our test cases that pollutes the results
            IgnoreDescriptors(options.IgnoreDescriptors);

            IgnoreSubstitutions(options.IgnoreSubstitutions);

            IgnoreLinkAttributes(options.IgnoreLinkAttributes);

#if !NETCOREAPP
            if (!string.IsNullOrEmpty(options.Il8n))
            {
                AddIl8n(options.Il8n);
            }
#endif

            if (!string.IsNullOrEmpty(options.KeepTypeForwarderOnlyAssemblies))
            {
                AddKeepTypeForwarderOnlyAssemblies(options.KeepTypeForwarderOnlyAssemblies);
            }

            if (!string.IsNullOrEmpty(options.LinkSymbols))
            {
                AddLinkSymbols(options.LinkSymbols);
            }

            if (!string.IsNullOrEmpty(options.KeepDebugMembers))
            {
                AddKeepDebugMembers(options.KeepDebugMembers);
            }

            AddSkipUnresolved(options.SkipUnresolved);

            AddStripDescriptors(options.StripDescriptors);

            AddStripSubstitutions(options.StripSubstitutions);

            AddStripLinkAttributes(options.StripLinkAttributes);

            foreach (var descriptor in options.Descriptors)
            {
                AddLinkXmlFile(descriptor);
            }

            foreach (var substitutions in options.Substitutions)
            {
                AddSubstitutions(substitutions);
            }

            foreach (var attributeDefinition in options.LinkAttributes)
            {
                AddLinkAttributes(attributeDefinition);
            }

            // A list of expensive optimizations which should not run by default
            AddAdditionalArgument("--disable-opt", new[] { "ipconstprop" });

            // Unity uses different argument format and needs to be able to translate to their format.  In order to make that easier
            // we keep the information in flag + values format for as long as we can so that this information doesn't have to be parsed out of a single string
            foreach (var additionalArgument in options.AdditionalArguments)
            {
                AddAdditionalArgument(additionalArgument.Key, additionalArgument.Value);
            }
        }
예제 #9
0
        public virtual TestCaseLinkerOptions GetLinkerOptions(NPath inputPath)
        {
            var tclo = new TestCaseLinkerOptions {
                Il8n = GetOptionAttributeValue(nameof(Il8nAttribute), "none"),
                IgnoreDescriptors               = GetOptionAttributeValue(nameof(IgnoreDescriptorsAttribute), true),
                IgnoreSubstitutions             = GetOptionAttributeValue(nameof(IgnoreSubstitutionsAttribute), true),
                IgnoreLinkAttributes            = GetOptionAttributeValue(nameof(IgnoreLinkAttributesAttribute), true),
                KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue(nameof(KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
                KeepDebugMembers        = GetOptionAttributeValue(nameof(SetupLinkerKeepDebugMembersAttribute), string.Empty),
                LinkSymbols             = GetOptionAttributeValue(nameof(SetupLinkerLinkSymbolsAttribute), string.Empty),
                TrimMode                = GetOptionAttributeValue <string> (nameof(SetupLinkerTrimModeAttribute), null),
                DefaultAssembliesAction = GetOptionAttributeValue <string> (nameof(SetupLinkerDefaultActionAttribute), null),
                SkipUnresolved          = GetOptionAttributeValue(nameof(SkipUnresolvedAttribute), false),
                StripDescriptors        = GetOptionAttributeValue(nameof(StripDescriptorsAttribute), true),
                StripSubstitutions      = GetOptionAttributeValue(nameof(StripSubstitutionsAttribute), true),
                StripLinkAttributes     = GetOptionAttributeValue(nameof(StripLinkAttributesAttribute), true),
            };

            foreach (var assemblyAction in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerActionAttribute)))
            {
                var ca = assemblyAction.ConstructorArguments;
                tclo.AssembliesAction.Add(new KeyValuePair <string, string> ((string)ca[0].Value, (string)ca[1].Value));
            }

            foreach (var descFile in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerDescriptorFile)))
            {
                var ca   = descFile.ConstructorArguments;
                var file = (string)ca[0].Value;
                tclo.Descriptors.Add(Path.Combine(inputPath, file));
            }

            foreach (var subsFile in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerSubstitutionFileAttribute)))
            {
                var ca   = subsFile.ConstructorArguments;
                var file = (string)ca[0].Value;
                tclo.Substitutions.Add(Path.Combine(inputPath, file));
            }

            foreach (var linkAttrFile in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkAttributesFile)))
            {
                var ca   = linkAttrFile.ConstructorArguments;
                var file = (string)ca[0].Value;
                tclo.LinkAttributes.Add(Path.Combine(inputPath, file));
            }

            foreach (var additionalArgumentAttr in _testCaseTypeDefinition.CustomAttributes.Where(attr => attr.AttributeType.Name == nameof(SetupLinkerArgumentAttribute)))
            {
                var ca     = additionalArgumentAttr.ConstructorArguments;
                var values = ((CustomAttributeArgument[])ca[1].Value)?.Select(arg => arg.Value.ToString()).ToArray();
                // Since custom attribute arguments need to be constant expressions, we need to add
                // the path to the temp directory (where the custom assembly is located) here.
                switch ((string)ca[0].Value)
                {
                case "--custom-step":
                    int pos = values[0].IndexOf(",");
                    if (pos != -1)
                    {
                        string custom_assembly_path = values[0].Substring(pos + 1);
                        if (!Path.IsPathRooted(custom_assembly_path))
                        {
                            values[0] = string.Concat(values[0].AsSpan(0, pos + 1), Path.Combine(inputPath, custom_assembly_path));
                        }
                    }
                    break;

                case "-a":
                    if (!Path.IsPathRooted(values[0]))
                    {
                        values[0] = Path.Combine(inputPath, values[0]);
                    }

                    break;
                }

                tclo.AdditionalArguments.Add(new KeyValuePair <string, string[]> ((string)ca[0].Value, values));
            }

            return(tclo);
        }