コード例 #1
0
        /// <summary>
        /// Creates global, compilation-wide diagnostic.
        /// </summary>
        public static Diagnostic CreateCompilerDiagnostic(IDiagnosticMessage message, params object[] args)
        {
            var text = DiagnosticUtilities.GetLocaleSpecificMessage(message);

            if (args?.Length > 0)
            {
                text = DiagnosticUtilities.FormatStringFromArgs(text, args);
            }

            return(new Diagnostic(text, message.Category, message.Code));
        }
コード例 #2
0
        /// <summary>
        /// Creates diagnostic instance for the file.
        /// </summary>
        public static Diagnostic CreateFileDiagnostic([NotNull] ISourceFile file, int start, int length, IDiagnosticMessage message, params object[] args)
        {
            Contract.Requires(start >= 0, "start must be non-negative");
            Contract.Requires(length >= 0, "length must be non-negative");

            var text = DiagnosticUtilities.GetLocaleSpecificMessage(message);

            // arguments is a javascript concept!!
            if (args?.Length > 0)
            {
                text = DiagnosticUtilities.FormatStringFromArgs(text, args);
            }

            return(new Diagnostic(file, start, length, text, message.Category, message.Code));
        }