{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://pvs-studio.com/pvs-studio-dotnet-schema.json",
  "title": "Structured log for the PVS-Studio C#",
  "type": "object",
  "required": [
    "pvsDiagVersion",
    "utility",
    "input",
    "output",
    "basicPerformance",
    "source"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Path to the data schema"
    },
    "pvsDiagVersion": {
      "type": "integer",
      "minimum": 1,
      "description": "Marker that this is a log from PVS tools and the format version"
    },
    "utility": {
      "$ref": "#/definitions/utility"
    },
    "input": {
      "$ref": "#/definitions/input"
    },
    "output": {
      "$ref": "#/definitions/output"
    },
    "basicPerformance": {
      "$ref": "#/definitions/basicPerformance"
    },
    "source": {
      "$ref": "#/definitions/source"
    }
  },
  "additionalProperties": false,
  "definitions": {
    "timepoint": {
      "$comment": "A point in time in extended ISO-8601 UTC+0 format (YYYY-MM-DDThh:mm:ss.sssZ)",
      "type": "string",
      "format": "date-time"
    },
    "durationNS": {
      "$comment": "Duration (in nanoseconds)",
      "type": "integer",
      "minimum": 0
    },
    "durationISO": {
      "$comment": "Duration in ISO-8601 format (hh:mm:ss.sssZ)",
      "type": "string",
      "format": "time"
    },
    "memorySize": {
      "$comment": "Amount of memory",
      "type": "integer",
      "minimum": 0
    },
    "utility": {
      "type": "object",
      "description": "Information about the utility that produced the log",
      "required": [
        "name",
        "path",
        "version",
        "hash",
        "isStable",
        "logVersion"
      ],
      "properties": {
        "name": {
          "type": "string",
          "const": "pvs-studio",
          "description": "Human-readable platform-independent utility name"
        },
        "path": {
          "type": "string",
          "description": "Path to the utility executable"
        },
        "version": {
          "type": "string",
          "description": "Utility version"
        },
        "hash": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{32}$",
          "description": "MD5 checksum of the utility file"
        },
        "isStable": {
          "type": "boolean",
          "description": "Release version flag"
        },
        "logVersion": {
          "type": "integer",
          "minimum": 1,
          "description": "Versioning of the log format for this specific utility"
        }
      },
      "additionalProperties": false
    },
    "input": {
      "type": "object",
      "description": "Utility input parameters (explicit and implicit)",
      "required": [
        "arguments",
        "cwd",
        "timestamp",
        "logging"
      ],
      "properties": {
        "arguments": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Utility command-line arguments"
        },
        "timestamp": {
          "$ref": "#/definitions/timepoint",
          "description": "Start date and time in ISO-8601 UTC+0 format (YYYY-MM-DDThh:mm:ss.sssZ)"
        },
        "logging": {
          "$ref": "#/definitions/logging"
        }
      },
      "additionalProperties": false
    },
    "logging": {
      "type": "object",
      "required": [
        "categories",
        "options",
        "sourceLog"
      ],
      "properties": {
        "categories": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "basic",
              "parser",
              "performance"
            ]
          },
          "minItems": 1,
          "description": "Logging categories"
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "skip-sensitive",
              "dump-intermediate-files",
              "performance"
            ]
          },
          "description": "Logging options"
        },
        "sourceLog": {
          "type": "string",
          "description": "Path to the raw log file the structured log was produced from"
        }
      },
      "additionalProperties": false
    },
    "output": {
      "type": "object",
      "description": "Utility results",
      "required": [
        "artifacts",
        "isFailed",
        "returnCode"
      ],
      "properties": {
        "artifacts": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Files produced during analysis"
        },
        "returnCode": {
          "$ref": "#/definitions/returnCode",
          "description": "Exit code"
        },
        "isFailed": {
          "type": "boolean",
          "description": "Whether the utility considers that it completed successfully"
        }
      },
      "additionalProperties": false
    },
    "basicPerformance": {
      "type": "object",
      "description": "Basic performance metrics",
      "required": [
        "elapsedTime",
        "elapsedTimeISO",
        "peakMemoryConsumption",
        "peakMemoryConsumptionMiB"
      ],
      "properties": {
        "elapsedTime": {
          "$ref": "#/definitions/durationNS",
          "description": "Elapsed time (nanoseconds)"
        },
        "elapsedTimeISO": {
          "$ref": "#/definitions/durationISO",
          "description": "Elapsed time in ISO-8601 format (hh:mm:ss.sssZ)"
        },
        "peakMemoryConsumption": {
          "$ref": "#/definitions/memorySize",
          "description": "Peak memory usage (bytes)"
        },
        "peakMemoryConsumptionMiB": {
          "$ref": "#/definitions/memorySize",
          "description": "Peak memory usage (MiB)"
        }
      },
      "additionalProperties": false
    },
    "source": {
      "type": "object",
      "description": "Information about the analyzed file",
      "required": [
        "comments",
        "sourceFilePath"
      ],
      "properties": {
        "sourceFilePath": {
          "type": "string",
          "minLength": 1,
          "description": "Path to the source file"
        },
        "comments": {
          "type": "object",
          "required": [
            "suppression"
          ],
          "properties": {
            "suppression": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/sourceCodeEntry"
              },
              "description": "Comments for suppressing warnings"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "sourceCodeEntry": {
      "$comment": "An entry inside the source code",
      "type": "object",
      "required": [
        "text",
        "source",
        "line"
      ],
      "properties": {
        "text": {
          "type": "string",
          "description": "Text"
        },
        "source": {
          "type": "string",
          "description": "Path to the source file"
        },
        "line": {
          "type": "integer",
          "description": "Line number in the source file"
        }
      },
      "additionalProperties": false
    },
    "returnCode": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Exit code. May be null."
    }
  }
}
