internal static CompilationWrites? TryParse()

in src/StructuredLogger/ObjectModel/Tasks/CompilationWrites.cs [34:92]


        internal static CompilationWrites? TryParse(Task task)
        {
            var parameters = task.FindChild<Folder>(c => c.Name == Strings.Parameters);
            if (parameters == null)
            {
                // Probably localized MSBuild that we don't yet support
                return null;
            }

            string assembly = null;
            string refAssembly = null;
            string xmlDocumentation = null;
            string sourceLink = null;
            var hasPdb = false;

            foreach (var property in parameters.Children.OfType<Property>())
            {
                switch (property.Name)
                {
                    case "OutputAssembly":
                        assembly = property.Value;
                        break;
                    case "OutputRefAssembly":
                        refAssembly = property.Value;
                        break;
                    case "DocumentationFile":
                        xmlDocumentation = property.Value;
                        break;
                    case "SourceLink":
                        sourceLink = property.Value;
                        break;
                    case "DebugType":
                        switch (property.Value.ToLower())
                        {
                            case "full":
                            case "portable":
                            case "pdbonly":
                                hasPdb = true;
                                break;
                        }
                        break;
                }
            }

            if (string.IsNullOrEmpty(assembly) && string.IsNullOrEmpty(refAssembly))
            {
                return null;
            }

            var pdb = hasPdb && !string.IsNullOrEmpty(assembly)
                ? Path.ChangeExtension(assembly, ".pdb")
                : null;
            return new CompilationWrites(
                assembly,
                refAssembly,
                pdb,
                xmlDocumentation,
                sourceLink);
        }