示例#1
0
        public void DataTest1()
        {
            var data = new SlnHeader();

            data.SetFormatVersion("11.00");
            data.SetProgramVersion("2010");
            data.SetVisualStudioVersion("14.0.25420.1");
            data.SetMinimumVersion("10.0.30319.1");

            Assert.NotNull(data.FormatVersion);
            Assert.NotNull(data.ProgramVersion);
            Assert.NotNull(data.VisualStudioVersion);
            Assert.NotNull(data.MinimumVisualStudioVersion);

            Assert.Equal(11, data.FormatVersion.Major);
            Assert.Equal(0, data.FormatVersion.Minor);

            Assert.Equal("2010", data.ProgramVersion);

            Assert.Equal(14, data.VisualStudioVersion.Major);
            Assert.Equal(0, data.VisualStudioVersion.Minor);
            Assert.Equal(25420, data.VisualStudioVersion.Build);
            Assert.Equal(1, data.VisualStudioVersion.Revision);

            Assert.Equal(10, data.MinimumVisualStudioVersion.Major);
            Assert.Equal(0, data.MinimumVisualStudioVersion.Minor);
            Assert.Equal(30319, data.MinimumVisualStudioVersion.Build);
            Assert.Equal(1, data.MinimumVisualStudioVersion.Revision);
        }
示例#2
0
        public void ExtractTest1()
        {
            var data = new SlnHeader();

            data.SetFormatVersion("11.00");
            data.SetProgramVersion("2010");
            data.SetVisualStudioVersion("14.0.25420.1");
            data.SetMinimumVersion("10.0.30319.1");

            var target = (new WVisualStudioVersion(data)).Extract(null);

            Assert.Equal(SlnSamplesResource.Section_Header, target);
        }
示例#3
0
        /// <summary>
        /// New position in stream.
        /// </summary>
        /// <param name="svc"></param>
        /// <param name="line">Received line.</param>
        /// <returns>true if it was processed by current handler, otherwise it means ignoring.</returns>
        public override bool Positioned(ISvc svc, RawText line)
        {
            int    pos = line.trimmed.LastIndexOfAny(new char[] { '=', ' ' });
            string version;

            if (pos == -1 ||
                lineType == LineType.Unknown ||
                String.IsNullOrWhiteSpace(version = line.trimmed.Substring(pos + 1)))
            {
                LSender.Send(this, $"Incorrect version info from header: '{line.trimmed}'", Message.Level.Warn);
                return(false);
            }

            LSender.Send(this, $"Found version from header: '{lineType}' = '{version}'", Message.Level.Info);

            var h = new SlnHeader(svc.Sln.Header);

            switch (lineType)
            {
            case LineType.FormatVersion: {
                h.SetFormatVersion(version);
                break;
            }

            case LineType.VisualStudioVersion: {
                h.SetVisualStudioVersion(version);
                break;
            }

            case LineType.MinimumVisualStudioVersion: {
                h.SetMinimumVersion(version);
                break;
            }

            case LineType.ProgramVersion: {
                h.SetProgramVersion(version);
                break;
            }

            default: {
                return(false);
            }
            }

            svc.Sln.SetHeader(h);
            return(true);
        }