コード例 #1
0
        public void SetOutput(RazorCSharpDocument csharpDocument, DefaultDocumentSnapshot document)
        {
            lock (_setOutputLock)
            {
                if (!document.TryGetTextVersion(out var version))
                {
                    Debug.Fail("The text version should have already been evaluated.");
                    return;
                }

                if (_sourceVersion.HasValue && _sourceVersion == SourceVersion.GetNewerVersion(version))
                {
                    // Latest document is newer than the provided document.
                    return;
                }

                if (!document.TryGetText(out var source))
                {
                    Debug.Fail("The text should have already been evaluated.");
                    return;
                }

                _source         = source;
                _sourceVersion  = version;
                _output         = csharpDocument;
                _latestDocument = document;
                _textContainer.SetText(SourceText.From(Output.GeneratedCode));
            }
        }
コード例 #2
0
        private string CreateBuildSourceInfo()
        {
            var parts        = SourceBranch.Split('/');
            var branchName   = parts.Last();
            var versionShort = String.Empty;

            if (!string.IsNullOrEmpty(SourceVersion))
            {
                versionShort = SourceVersion.Substring(0, 7);
            }
            return($"{branchName} {versionShort}");
        }
コード例 #3
0
        /// <summary>
        /// Reports referenced package to a console.
        /// </summary>
        public void Report()
        {
            if (String.IsNullOrEmpty(PackageId))
            {
                throw new InvalidOperationException("Package ID is not specified.");
            }

            if (String.IsNullOrEmpty(ProjectName))
            {
                throw new InvalidOperationException(
                          String.Format("Project name is missing for package '{0}'.", PackageId));
            }

            if (String.IsNullOrEmpty(ProjectUrl))
            {
                throw new InvalidOperationException(
                          String.Format("Project URL is missing for package '{0}'.", PackageId));
            }

            if (BuildVersion == null)
            {
                throw new InvalidOperationException(
                          String.Format("Build version is missing for package '{0}'.", PackageId));
            }

            if (IsDependency && IsBundle)
            {
                throw new InvalidOperationException(
                          String.Format("Both dependency and bundle cannot be specified for package '{0}'.", PackageId));
            }

            string source;

            if (SourceVersion == null)
            {
                source = "n/a";
            }
            else
            {
                source = SourceVersion.Normalize().ToString();
            }

            var build = BuildVersion.Normalize().ToString();

            if (ProjectReference)
            {
                source = source + " (csproj)";
            }

            Execute.ReportPackage(ProjectName, ProjectUrl, source, build, Comment);
        }
コード例 #4
0
        private string GetCommitIdUpToXDigitsOrChangeSetId(SourceVersion sourceVersion, int digitsOfInterest)
        {
            if (sourceVersion == null)
            {
                return(null);
            }

            if (sourceVersion.id.StartsWith("C"))
            {
                sourceVersion.id = sourceVersion.id.Substring(1, sourceVersion.id.Length - 1);
            }

            var sourceIdLength = sourceVersion.id.Length;

            return(sourceVersion.id.Substring(0, Math.Min(digitsOfInterest, sourceIdLength)));
        }
コード例 #5
0
        public override SourceVersion GetSupportedSourceVersion()
        {
            SourceVersion latestSupported = SourceVersion.LatestSupported();

            if ((int)(latestSupported) <= 6)
            {
                return(SourceVersion.Release6);
            }
            else
            {
                if ((int)(latestSupported) <= 8)
                {
                    return(latestSupported);
                }
                else
                {
                    // this annotation processor is tested through Java 8
                    return(SourceVersion.Values()[8]);
                }
            }
        }
コード例 #6
0
 /**
  * Determine if the given symbol is a legal proposition symbol.
  *
  * @param symbol
  *            a symbol to be tested.
  * @return true if the given symbol is a legal proposition symbol, false
  *         otherwise.
  */
 public static bool isPropositionSymbol(string symbol)
 {
     return(SourceVersion.IsIdentifier(symbol));
 }