Beispiel #1
0
        public bool TryCreateTimelineQuery(IssueKind kind, GitHubIssueKey issueKey, string text)
        {
            if (TryGetTimelineQuery(issueKey, out var timelineQuery))
            {
                return(false);
            }

            timelineQuery = new ModelTimelineQuery()
            {
                GitHubOrganization = issueKey.Organization,
                GitHubRepository   = issueKey.Repository,
                IssueNumber        = issueKey.Number,
                SearchText         = text
            };

            try
            {
                Context.ModelTimelineQueries.Add(timelineQuery);
                Context.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
Beispiel #2
0
        public AnalyzerConfig(
            bool isEnabled,
            IssueKind issueKind,
            Importance infoImportance,
            TimeSpan[] analyzerServiceCallRetryTimeSpans,
            string[] sourcePathExclusionPatterns,

            bool childCanDependOnParentImplicitly,
            Dictionary <NamespaceDependencyRule, TypeNameSet> allowRules,
            HashSet <NamespaceDependencyRule> disallowRules,
            Dictionary <Namespace, TypeNameSet> visibleTypesByNamespace,
            int maxIssueCount,
            IssueKind maxIssueCountSeverity,
            bool autoLowerMaxIssueCount)
        {
            IsEnabled = isEnabled;
            DependencyIssueSeverity           = issueKind;
            InfoImportance                    = infoImportance;
            AnalyzerServiceCallRetryTimeSpans = analyzerServiceCallRetryTimeSpans;
            SourcePathExclusionPatterns       = sourcePathExclusionPatterns;

            ChildCanDependOnParentImplicitly = childCanDependOnParentImplicitly;
            AllowRules              = allowRules;
            DisallowRules           = disallowRules;
            VisibleTypesByNamespace = visibleTypesByNamespace;
            MaxIssueCount           = maxIssueCount;
            MaxIssueCountSeverity   = maxIssueCountSeverity;
            AutoLowerMaxIssueCount  = autoLowerMaxIssueCount;
        }
Beispiel #3
0
        private void WriteJsonIssue(string binary, string ruleId, string message, IssueKind issueKind)
        {
            Issue issue = new Issue();

            issue.RuleId                  = ruleId;
            issue.FullMessage             = message;
            issue.Properties              = new Dictionary <string, string>();
            issue.Properties["issueKind"] = issueKind.ToString().ToLowerInvariant()[0] + issueKind.ToString().Substring(1);
            issue.Locations               = new[] {
                new Sarif.DataContracts.Location {
                    AnalysisTarget = new[]
                    {
                        new PhysicalLocationComponent
                        {
                            // Why? When NewtonSoft serializes this Uri, it will use the
                            // original string used to construct the Uri. For a file path,
                            // this will be the local file path. We want to persist this
                            // information using the file:// protocol rendering, however.
                            Uri      = binary.CreateUriForJsonSerialization(),
                            MimeType = MimeType.Binary
                        }
                    }
                }
            };

            _issueLogJsonWriter.WriteIssue(issue);
        }
Beispiel #4
0
        protected GameObjectIssueRecord(IssueKind kind, RecordLocation location, string path, GameObject gameObject, Type componentType, string componentName, int componentIndex, string propertyPath) : this(kind, location, path, gameObject, componentType, componentName, componentIndex)
        {
            this.propertyPath = propertyPath;

            if (propertyPath.EndsWith("].m_MethodName", StringComparison.OrdinalIgnoreCase))
            {
                missingEventMethod = true;
            }
        }
Beispiel #5
0
 protected GameObjectIssueRecord(IssueKind kind, RecordLocation location, string path, GameObject gameObject, Type componentType, string componentName, int componentIndex) : this(kind, location, path, gameObject)
 {
     this.componentName  = componentName;
     this.componentIndex = componentIndex;
     if (this.componentIndex > 0 && componentType != null && gameObject.GetComponents(componentType).Length > 1)
     {
         componentNamePostfix = " (#" + this.componentIndex + ")";
     }
 }
        protected ScriptableObjectIssueRecord(IssueKind kind, string path, string typeName, string propertyPath) : this(kind, path, typeName)
        {
            this.propertyPath = propertyPath;

            if (propertyPath.EndsWith("].m_MethodName", StringComparison.OrdinalIgnoreCase))
            {
                missingEventMethod = true;
            }
        }
Beispiel #7
0
        protected GameObjectIssueRecord(IssueKind kind, RecordLocation location, string path, GameObject gameObject) : base(kind, location, path)
        {
            var transform = gameObject.transform;

            transformPath = CSEditorTools.GetFullTransformPath(transform);

            if (kind != IssueKind.MissingPrefab)
            {
                objectId = CSObjectTools.GetUniqueObjectId(gameObject);
            }
        }
Beispiel #8
0
        public CodeIssue(int line, IssueKind kind, string message)
        {
            if (line < 0)
                throw new ArgumentOutOfRangeException("line", "line must be >= 0.");
            if (message == null)
                throw new ArgumentNullException("message");

            Line = line;
            Kind = kind;
            Message = message;
        }
Beispiel #9
0
        public AnalyzerConfig(bool isEnabled, IssueKind issueKind, Importance infoImportance, bool childCanDependOnParentImplicitly, Dictionary <NamespaceDependencyRule, TypeNameSet> allowRules, HashSet <NamespaceDependencyRule> disallowRules, Dictionary <Namespace, TypeNameSet> visibleTypesByNamespace, int maxIssueCount, int?maxWarningErrorThreshold)
        {
            IsEnabled      = isEnabled;
            IssueKind      = issueKind;
            InfoImportance = infoImportance;

            ChildCanDependOnParentImplicitly = childCanDependOnParentImplicitly;
            AllowRules               = allowRules;
            DisallowRules            = disallowRules;
            VisibleTypesByNamespace  = visibleTypesByNamespace;
            MaxIssueCount            = maxIssueCount;
            MaxWarningErrorThreshold = maxWarningErrorThreshold;
        }
        /// <summary>
        /// Translates from Codartis.NsDepCop.Core.IssueKind to Microsoft.CodeAnalysis.DiagnosticSeverity.
        /// </summary>
        /// <param name="issueKind">An IssueKind value.</param>
        /// <returns>A Microsoft.CodeAnalysis.DiagnosticSeverity value.</returns>
        public static DiagnosticSeverity ToDiagnosticSeverity(IssueKind issueKind)
        {
            switch (issueKind)
            {
            case IssueKind.Error:
                return(DiagnosticSeverity.Error);

            case IssueKind.Info:
                return(DiagnosticSeverity.Info);

            case IssueKind.Hidden:
                return(DiagnosticSeverity.Hidden);

            case IssueKind.Warning:
                return(DiagnosticSeverity.Warning);

            default:
                throw new ArgumentOutOfRangeException(nameof(issueKind), issueKind, "Unexpected value.");
            }
        }
        /// <summary>
        ///   Writes an issue, using the VSTS logging commands if running inside VSTS. Forwards to stderr if outside of VSTS.
        /// </summary>
        public static void LogIssue(this IConsole console, IssueKind kind, string message, string file = null, int?line = null, int?column = null)
        {
            var(type, color) = (kind) switch
            {
                IssueKind.Warning => ("warning", ConsoleColor.Yellow),
                IssueKind.Error => ("error", ConsoleColor.Red),
                _ => throw new ArgumentException("Invalid IssueKind", nameof(kind)),
            };
            if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AGENT_ID")))
            {
                console.Error(VerbosityLevel.Quiet, $"##vso[task.logissue type={type};sourcepath={file};linenumber={line};columnnumber={column};]{message}\n", ConsoleColor.Black);
                if (kind == IssueKind.Error)
                {
                    console.Error(VerbosityLevel.Quiet, "##vso[task.complete result=Failed;]", ConsoleColor.Black);
                }
            }
            else
            {
                var m = new StringBuilder();
                if (!string.IsNullOrEmpty(file))
                {
                    m.Append(file);
                    if (line != null)
                    {
                        if (column != null)
                        {
                            m.Append($"({line},{column})");
                        }
                        else
                        {
                            m.Append($"({line})");
                        }
                    }

                    m.Append(": ");
                }

                m.Append($"{type} : {message}\n");
                console.Error(VerbosityLevel.Quiet, m.ToString(), color);
            }
        }
        private void LogBuildEvent(IssueKind issueKind, string message, MessageImportance messageImportance, string code = null,
                                   string path = null, int startLine = 0, int startColumn = 0, int endLine = 0, int endColumn = 0)
        {
            switch (issueKind)
            {
            case IssueKind.Error:
                _buildEngine.LogErrorEvent(new BuildErrorEventArgs(
                                               null, code, path, startLine, startColumn, endLine, endColumn, message, code, ProductConstants.ToolName));
                break;

            case IssueKind.Warning:
                _buildEngine.LogWarningEvent(new BuildWarningEventArgs(
                                                 null, code, path, startLine, startColumn, endLine, endColumn, message, code, ProductConstants.ToolName));
                break;

            default:
                var formattedMessage = $"[{ProductConstants.ToolName}] {message}";
                _buildEngine.LogMessageEvent(new BuildMessageEventArgs(
                                                 null, code, path, startLine, startColumn, endLine, endColumn, formattedMessage, code, ProductConstants.ToolName, messageImportance));
                break;
            }
        }
 internal static SceneSettingsIssueRecord Create(SceneSettingsKind settingsKind, IssueKind issueKind, string path, string propertyPath)
 {
     return(new SceneSettingsIssueRecord(settingsKind, issueKind, path, propertyPath));
 }
        private static Diagnostic CreateTooManyIssuesDiagnostic(SyntaxNode node, string message, IssueKind issueKind)
        {
            var location = Location.Create(node.SyntaxTree, node.Span);

            return(CreateDiagnostic(IllegalDependencyDescriptor, location, message, issueKind));
        }
        private static Diagnostic CreateIllegalDependencyDiagnostic(SyntaxNode node, string message, IssueKind issueKind)
        {
            // TODO: get location from typeDependency.SourceSegment?
            var location = Location.Create(node.SyntaxTree, node.Span);

            return(CreateDiagnostic(IllegalDependencyDescriptor, location, message, issueKind));
        }
Beispiel #16
0
        private static Diagnostic CreateIllegalDependencyDiagnostic(SyntaxNode node, TypeDependency typeDependency, IssueKind issueKind)
        {
            // TODO: get location from typeDependency.SourceSegment?
            var location = Location.Create(node.SyntaxTree, node.Span);
            var message  = IssueDefinitions.IllegalDependencyIssue.GetDynamicDescription(typeDependency);

            return(CreateDiagnostic(IllegalDependencyDescriptor, location, message, issueKind));
        }
Beispiel #17
0
 protected SettingsIssueRecord(AssetSettingsKind settingsKind, IssueKind kind, string body) : base(kind, RecordLocation.Asset, null)
 {
     SettingsKind = settingsKind;
     bodyExtra    = body;
 }
Beispiel #18
0
 public TooManyIssuesMessage(int maxIssueCount, IssueKind issueKind)
 {
     MaxIssueCount = maxIssueCount;
     IssueKind     = issueKind;
 }
Beispiel #19
0
 internal static SettingsIssueRecord Create(AssetSettingsKind settingsKind, IssueKind type, string path, string propertyPath)
 {
     return(new SettingsIssueRecord(settingsKind, type, path, propertyPath));
 }
Beispiel #20
0
 internal static GameObjectIssueRecord Create(IssueKind type, RecordLocation location, string path, GameObject gameObject)
 {
     return(new GameObjectIssueRecord(type, location, path, gameObject));
 }
        /// <summary>
        /// Provides the color associated to the issue kind
        /// </summary>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static Color IssueColor(IssueKind? kind)
        {
            Color retVal = Colors.IndianRed;

            if (kind == IssueKind.Comment)
            {
                retVal = Colors.LightGreen;
            }
            else if (kind == IssueKind.Question)
            {
                retVal = Colors.LightGoldenrodYellow;
            }
            else if (kind == IssueKind.OutOfScope)
            {
                retVal = Colors.MediumPurple;
            }
            else if (kind == null)
            {
                retVal = Colors.Transparent;
            }

            return retVal;
        }
Beispiel #22
0
 public IssueDescriptor(string id, IssueKind defaultKind, string staticDescription)
 {
     Id                = id;
     DefaultKind       = defaultKind;
     StaticDescription = staticDescription;
 }
 protected IssueMessageBase(IssueType issueType, IssueKind issueKind)
 {
     IssueType = issueType;
     IssueKind = issueKind;
 }
 public IllegalDependencyMessage(TypeDependency illegalDependency, IssueKind issueKind)
 {
     IllegalDependency = illegalDependency;
     IssueKind         = issueKind;
 }
Beispiel #25
0
 public IssueDescriptor(string id, IssueKind defaultKind, string title)
 {
     Id          = id;
     DefaultKind = defaultKind;
     Title       = title;
 }
 protected SceneSettingsIssueRecord(SceneSettingsKind settingsKind, IssueKind issueKind, string path, string propertyPath) : base(issueKind, RecordLocation.Scene, path)
 {
     SettingsKind = settingsKind;
     PropertyPath = propertyPath;
 }
Beispiel #27
0
 internal static GameObjectIssueRecord Create(IssueKind type, RecordLocation location, string path, GameObject gameObject, Type componentType, string componentName, int componentIndex, string propertyPath)
 {
     return(new GameObjectIssueRecord(type, location, path, gameObject, componentType, componentName, componentIndex, propertyPath));
 }
        public static FixResult FixObjectIssue(GameObjectIssueRecord issue, Object obj, Component component, IssueKind type)
        {
            FixResult result;

            if (type == IssueKind.MissingComponent)
            {
                var hasIssue = GameObjectHasMissingComponent(obj as GameObject);

                if (hasIssue)
                {
                    FixMissingComponents(issue, obj as GameObject, false);
                    if (!GameObjectHasMissingComponent(obj as GameObject))
                    {
                        result = new FixResult(true);
                    }
                    else
                    {
                        result = FixResult.CreateError("Fix attempt failed!");
                    }
                }
                else
                {
                    result = new FixResult(true);
                }
            }
            else if (type == IssueKind.MissingReference)
            {
                result = FixMissingReference(component != null ? component : obj, issue.propertyPath, issue.Location);
            }
            else
            {
                result = FixResult.CreateError("IssueKind is not supported!");
            }

            return(result);
        }
Beispiel #29
0
 internal static SettingsIssueRecord Create(AssetSettingsKind settingsKind, IssueKind type, string body)
 {
     return(new SettingsIssueRecord(settingsKind, type, body));
 }
Beispiel #30
0
        private void WriteJsonIssue(string binary, string ruleId, string message, IssueKind issueKind)
        {
            Issue issue = new Issue();
            issue.RuleId = ruleId;
            issue.FullMessage = message;
            issue.Properties = new Dictionary<string, string>();
            issue.Properties["issueKind"] = issueKind.ToString().ToLowerInvariant()[0] + issueKind.ToString().Substring(1);
            issue.Locations = new[]{
                new Location {
                    AnalysisTarget = new[]
                    {
                        new PhysicalLocationComponent
                        {
                            // Why? When NewtonSoft serializes this Uri, it will use the
                            // original string used to construct the Uri. For a file path,
                            // this will be the local file path. We want to persist this
                            // information using the file:// protocol rendering, however.
                            Uri = binary.CreateUriForJsonSerialization(),
                            MimeType = MimeType.Binary
                        }
                    }
                }
            };

            _issueLogJsonWriter.WriteIssue(issue);
        }
 public TooManyIssuesMessage(int maxIssueCount, IssueKind issueKind)
     : base(IssueType.TooManyIssues, issueKind)
 {
     MaxIssueCount = maxIssueCount;
 }
 public TestIssueMessage(string code, IssueKind issueKind, string title)
 {
     Code      = code;
     IssueKind = issueKind;
     Title     = title;
 }
Beispiel #33
0
 protected SettingsIssueRecord(AssetSettingsKind settingsKind, IssueKind kind, string path, string propertyPath) : base(kind, RecordLocation.Asset, path)
 {
     SettingsKind = settingsKind;
     PropertyPath = propertyPath;
 }