diff --git a/LanguageMaster.xml b/LanguageMaster.xml index cc0a756b86..b706e3177b 100644 --- a/LanguageMaster.xml +++ b/LanguageMaster.xml @@ -1051,6 +1051,7 @@ Note: Do check free disk space. Remove text for hearing impaired Visual sync Spell check + Netflix quality check Settings Help Show/hide waveform @@ -1675,6 +1676,7 @@ can edit in same subtitle file (collaboration) Replace Visual sync Spell check + Netflix quality check Settings Help Show frame rate in toolbar @@ -1975,6 +1977,14 @@ can edit in same subtitle file (collaboration) Spell check aborted Undo: {0} + + Character validation successful. + Character validation failed. Refer to the Netflix Glyph List for valid characters. Please see the full report here: {0}. + Invalid character {0} found at column {1}. + White space validation successful. + White space validation failed. Please see the full report here: {0}. + Invalid white space found at column {0}. + Split Split options diff --git a/libse/Language.cs b/libse/Language.cs index 53a6fd78cc..a9e12e7cfd 100644 --- a/libse/Language.cs +++ b/libse/Language.cs @@ -85,6 +85,7 @@ public class Language public LanguageStructure.ShowEarlierLater ShowEarlierLater; public LanguageStructure.ShowHistory ShowHistory; public LanguageStructure.SpellCheck SpellCheck; + public LanguageStructure.NetflixQualityCheck NetflixQualityCheck; public LanguageStructure.Split Split; public LanguageStructure.SplitLongLines SplitLongLines; public LanguageStructure.SplitSubtitle SplitSubtitle; @@ -1549,6 +1550,7 @@ public Language() RemoveTextForHi = "Remove text for hearing impaired", VisualSync = "Visual sync", SpellCheck = "Spell check", + NetflixQualityCheck = "Netflix quality check", Settings = "Settings", Help = "Help", ShowHideWaveform = "Show/hide waveform", @@ -1959,6 +1961,7 @@ can edit in same subtitle file (collaboration)", Replace = "Replace", VisualSync = "Visual sync", SpellCheck = "Spell check", + NetflixQualityCheck = "Netflix quality check", SettingsName = "Settings", Help = "Help", ShowFrameRate = "Show frame rate in toolbar", @@ -2268,6 +2271,17 @@ can edit in same subtitle file (collaboration)", UndoX = "Undo: {0}", }; + NetflixQualityCheck = new LanguageStructure.NetflixQualityCheck + { + GlyphCheckSuccessfull = "Character validation successful.", + GlyphCheckFailed = "Character validation failed. Refer to the Netflix Glyph List for valid characters. Please see the full report here: {0}.", + GlyphCheckReport = "Invalid character {0} found at column {1}.", + + WhiteSpaceCheckSuccessfull = "White space validation successful.", + WhiteSpaceCheckFailed = "White space validation failed. Please see the full report here: {0}.", + WhiteSpaceCheckReport = "Invalid white space found at column {0}." + }; + Split = new LanguageStructure.Split { Title = "Split", diff --git a/libse/LanguageDeserializer.cs b/libse/LanguageDeserializer.cs index 10923a95a4..a37ad5047c 100644 --- a/libse/LanguageDeserializer.cs +++ b/libse/LanguageDeserializer.cs @@ -3346,6 +3346,9 @@ private static void SetValue(Language language, XmlReader reader, string name) case "Main/Menu/Tools/SortBy": language.Main.Menu.Tools.SortBy = reader.Value; break; + case "Main/Menu/Tools/NetflixQualityCheck": + language.Main.Menu.Tools.NetflixQualityCheck = reader.Value; + break; case "Main/Menu/Tools/Number": language.Main.Menu.Tools.Number = reader.Value; break; @@ -3565,6 +3568,9 @@ private static void SetValue(Language language, XmlReader reader, string name) case "Main/Menu/ToolBar/SpellCheck": language.Main.Menu.ToolBar.SpellCheck = reader.Value; break; + case "Main/Menu/ToolBar/NetflixQualityCheck": + language.Main.Menu.ToolBar.NetflixQualityCheck = reader.Value; + break; case "Main/Menu/ToolBar/Settings": language.Main.Menu.ToolBar.Settings = reader.Value; break; @@ -4474,6 +4480,9 @@ private static void SetValue(Language language, XmlReader reader, string name) case "Settings/SpellCheck": language.Settings.SpellCheck = reader.Value; break; + case "Settings/NetflixQualityCheck": + language.Settings.NetflixQualityCheck = reader.Value; + break; case "Settings/SettingsName": language.Settings.SettingsName = reader.Value; break; @@ -5341,6 +5350,24 @@ private static void SetValue(Language language, XmlReader reader, string name) case "SpellCheck/UndoX": language.SpellCheck.UndoX = reader.Value; break; + case "NetflixQualityCheck/GlyphCheckSuccessfull": + language.NetflixQualityCheck.GlyphCheckSuccessfull = reader.Value; + break; + case "NetflixQualityCheck/GlyphCheckFailed": + language.NetflixQualityCheck.GlyphCheckFailed = reader.Value; + break; + case "NetflixQualityCheck/GlyphCheckReport": + language.NetflixQualityCheck.GlyphCheckReport = reader.Value; + break; + case "NetflixQualityCheck/WhiteSpaceCheckSuccessfull": + language.NetflixQualityCheck.WhiteSpaceCheckSuccessfull = reader.Value; + break; + case "NetflixQualityCheck/WhiteSpaceCheckFailed": + language.NetflixQualityCheck.WhiteSpaceCheckFailed = reader.Value; + break; + case "NetflixQualityCheck/WhiteSpaceCheckReport": + language.NetflixQualityCheck.WhiteSpaceCheckReport = reader.Value; + break; case "Split/Title": language.Split.Title = reader.Value; break; diff --git a/libse/LanguageStructure.cs b/libse/LanguageStructure.cs index a2da35067f..ac3a5ac6bf 100644 --- a/libse/LanguageStructure.cs +++ b/libse/LanguageStructure.cs @@ -1313,6 +1313,7 @@ public class ToolsMenu public string SplitLongLines { get; set; } public string MinimumDisplayTimeBetweenParagraphs { get; set; } public string SortBy { get; set; } + public string NetflixQualityCheck { get; set; } public string Number { get; set; } public string StartTime { get; set; } public string EndTime { get; set; } @@ -1413,6 +1414,7 @@ public class ToolBarMenu public string RemoveTextForHi { get; set; } public string VisualSync { get; set; } public string SpellCheck { get; set; } + public string NetflixQualityCheck { get; set; } public string Settings { get; set; } public string Help { get; set; } public string ShowHideWaveform { get; set; } @@ -1836,6 +1838,7 @@ public class Settings public string Replace { get; set; } public string VisualSync { get; set; } public string SpellCheck { get; set; } + public string NetflixQualityCheck { get; set; } public string SettingsName { get; set; } public string Help { get; set; } public string ShowFrameRate { get; set; } @@ -2148,6 +2151,17 @@ public class SpellCheck public string UndoX { get; set; } } + public class NetflixQualityCheck + { + public string GlyphCheckSuccessfull { get; set; } + public string GlyphCheckFailed { get; set; } + public string GlyphCheckReport { get; set; } + + public string WhiteSpaceCheckSuccessfull { get; set; } + public string WhiteSpaceCheckFailed { get; set; } + public string WhiteSpaceCheckReport { get; set; } + } + public class Split { public string Title { get; set; } diff --git a/libse/LibSE.csproj b/libse/LibSE.csproj index f098cd830e..ac1892d1c8 100644 --- a/libse/LibSE.csproj +++ b/libse/LibSE.csproj @@ -175,10 +175,19 @@ + + + + + + True + True + Resources.resx + @@ -502,6 +511,16 @@ + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + diff --git a/libse/NetflixQualityCheck/INetflixQualityChecker.cs b/libse/NetflixQualityCheck/INetflixQualityChecker.cs new file mode 100644 index 0000000000..6a121f1b20 --- /dev/null +++ b/libse/NetflixQualityCheck/INetflixQualityChecker.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck +{ + public interface INetflixQualityChecker + { + void Check(Subtitle subtitle, NetflixQualityReportBuilder report); + } +} diff --git a/libse/NetflixQualityCheck/NetflixGlyphChecker.cs b/libse/NetflixQualityCheck/NetflixGlyphChecker.cs new file mode 100644 index 0000000000..2e8102d9a4 --- /dev/null +++ b/libse/NetflixQualityCheck/NetflixGlyphChecker.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck +{ + public class NetflixGlyphChecker : INetflixQualityChecker + { + private static int[] LoadNetflixGlyphs() + { + int[] glyphs; + + using (MemoryStream ms = new MemoryStream(Properties.Resources.NetflixAllowedGlyphs)) + { + using (BinaryReader br = new BinaryReader(ms)) + { + const int codepointSize = 4; + long n = ms.Length / codepointSize; + glyphs = new int[n]; + + for (int i = 0; i < n; i++) + { + glyphs[i] = br.ReadInt32(); + } + } + } + + return glyphs; + } + + public void Check(Subtitle subtitle, NetflixQualityReportBuilder report) + { + // Load allowed glyphs + int[] allowedGlyphsArr = LoadNetflixGlyphs(); + HashSet allowedGlyphsSet = new HashSet(allowedGlyphsArr); + + foreach (Paragraph paragraph in subtitle.Paragraphs) + { + for (int pos = 0, actualPos = 0; pos < paragraph.Text.Length; + pos += char.IsSurrogatePair(paragraph.Text, pos) ? 2 : 1, actualPos++) + { + int curCodepoint = char.ConvertToUtf32(paragraph.Text, pos); + + if (!allowedGlyphsSet.Contains(curCodepoint)) + { + string timecode = paragraph.StartTime.ToHHMMSSFF(); + string context = NetflixQualityReportBuilder.StringContext(paragraph.Text, pos, 6); + string comment = string.Format(Configuration.Settings.Language.NetflixQualityCheck.GlyphCheckReport, + string.Format("U+{0:X}", curCodepoint), actualPos); + + report.AddRecord(timecode, context, comment); + } + } + } + } + + } +} diff --git a/libse/NetflixQualityCheck/NetflixQualityReportBuilder.cs b/libse/NetflixQualityCheck/NetflixQualityReportBuilder.cs new file mode 100644 index 0000000000..f46a2a7934 --- /dev/null +++ b/libse/NetflixQualityCheck/NetflixQualityReportBuilder.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck +{ + public class NetflixQualityReportBuilder + { + public class Record + { + public string Timecode { get; set; } + public string Context { get; set; } + public string Comment { get; set; } + + public Record(string timecode, string context, string comment) + { + Timecode = timecode; + Context = context; + Comment = comment; + } + + public string ToCSVRow() + { + string safeContext = Context; + safeContext = safeContext.Replace("\"", "\"\""); + safeContext = safeContext.Replace("\r\n", "\n"); + safeContext = safeContext.Replace("\n", "\\n"); + safeContext = string.Format("\"{0}\"", safeContext); + + return string.Format("{0},{1},{2}", Timecode, safeContext, Comment); + } + } + + public List Records { get; private set; } + + public NetflixQualityReportBuilder() + { + Records = new List(); + } + + public void AddRecord(string timecod, string context, string comment) + { + Records.Add(new Record(timecod, context, comment)); + } + + public string ExportCSV() + { + StringBuilder csvBuilder = new StringBuilder(); + + // Header + csvBuilder.AppendLine("Timecode,Context,Comment"); + + // Rows + Records.ForEach(r => csvBuilder.AppendLine(r.ToCSVRow())); + + return csvBuilder.ToString(); + } + + public bool IsEmpty { + get + { + return Records.Count == 0; + } + } + + public static string StringContext(string str, int pos, int radius) + { + int beginPos = Math.Max(0, pos - radius); + int endPos = Math.Min(str.Length, pos + radius); + int length = endPos - beginPos; + return str.Substring(beginPos, length); + } + } +} diff --git a/libse/NetflixQualityCheck/NetflixWhiteSpaceChecker.cs b/libse/NetflixQualityCheck/NetflixWhiteSpaceChecker.cs new file mode 100644 index 0000000000..52b3b668ee --- /dev/null +++ b/libse/NetflixQualityCheck/NetflixWhiteSpaceChecker.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck +{ + public class NetflixWhiteSpaceChecker : INetflixQualityChecker + { + public void Check(Subtitle subtitle, NetflixQualityReportBuilder report) + { + foreach (Paragraph p in subtitle.Paragraphs) + { + foreach (Match m in Regex.Matches(p.Text, "([ ]{2,}|(\n|\r\n){2,})")) + { + string timecode = p.StartTime.ToHHMMSSFF(); + string context = NetflixQualityReportBuilder.StringContext(p.Text, m.Index, 6); + string comment = string.Format(Configuration.Settings.Language.NetflixQualityCheck.WhiteSpaceCheckReport, m.Index); + + report.AddRecord(timecode, context, comment); + } + } + } + } +} diff --git a/libse/Properties/Resources.Designer.cs b/libse/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..31f743a814 --- /dev/null +++ b/libse/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Nikse.SubtitleEdit.Core.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Nikse.SubtitleEdit.Core.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Byte[]. + /// + internal static byte[] NetflixAllowedGlyphs { + get { + object obj = ResourceManager.GetObject("NetflixAllowedGlyphs", resourceCulture); + return ((byte[])(obj)); + } + } + } +} diff --git a/libse/Properties/Resources.resx b/libse/Properties/Resources.resx new file mode 100644 index 0000000000..536a1d988c --- /dev/null +++ b/libse/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\NetflixAllowedGlyphs.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/libse/Resources/NetflixAllowedGlyphs.bin b/libse/Resources/NetflixAllowedGlyphs.bin new file mode 100644 index 0000000000..63cd5946c2 Binary files /dev/null and b/libse/Resources/NetflixAllowedGlyphs.bin differ diff --git a/libse/Settings.cs b/libse/Settings.cs index f33daef26c..5d327e6a49 100644 --- a/libse/Settings.cs +++ b/libse/Settings.cs @@ -493,6 +493,7 @@ public class GeneralSettings public bool ShowToolbarRemoveTextForHi { get; set; } public bool ShowToolbarVisualSync { get; set; } public bool ShowToolbarSpellCheck { get; set; } + public bool ShowToolbarNetflixGlyphCheck { get; set; } public bool ShowToolbarSettings { get; set; } public bool ShowToolbarHelp { get; set; } @@ -603,6 +604,7 @@ public GeneralSettings() ShowToolbarFixCommonErrors = false; ShowToolbarVisualSync = true; ShowToolbarSpellCheck = true; + ShowToolbarNetflixGlyphCheck = true; ShowToolbarSettings = false; ShowToolbarHelp = true; @@ -1352,6 +1354,9 @@ private static Settings CustomDeserialize(string fileName) subNode = node.SelectSingleNode("ShowToolbarSpellCheck"); if (subNode != null) settings.General.ShowToolbarSpellCheck = Convert.ToBoolean(subNode.InnerText); + subNode = node.SelectSingleNode("ShowToolbarNetflixGlyphCheck"); + if (subNode != null) + settings.General.ShowToolbarNetflixGlyphCheck = Convert.ToBoolean(subNode.InnerText); subNode = node.SelectSingleNode("ShowToolbarSettings"); if (subNode != null) settings.General.ShowToolbarSettings = Convert.ToBoolean(subNode.InnerText); @@ -3015,6 +3020,7 @@ private static void CustomSerialize(string fileName, Settings settings) textWriter.WriteElementString("ShowToolbarRemoveTextForHi", settings.General.ShowToolbarRemoveTextForHi.ToString()); textWriter.WriteElementString("ShowToolbarVisualSync", settings.General.ShowToolbarVisualSync.ToString()); textWriter.WriteElementString("ShowToolbarSpellCheck", settings.General.ShowToolbarSpellCheck.ToString()); + textWriter.WriteElementString("ShowToolbarNetflixGlyphCheck", settings.General.ShowToolbarNetflixGlyphCheck.ToString()); textWriter.WriteElementString("ShowToolbarSettings", settings.General.ShowToolbarSettings.ToString()); textWriter.WriteElementString("ShowToolbarHelp", settings.General.ShowToolbarHelp.ToString()); textWriter.WriteElementString("ShowFrameRate", settings.General.ShowFrameRate.ToString()); diff --git a/libse/SubtitleFormats/TimedText10.cs b/libse/SubtitleFormats/TimedText10.cs index 864892cc7d..496847ea73 100644 --- a/libse/SubtitleFormats/TimedText10.cs +++ b/libse/SubtitleFormats/TimedText10.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Text; using System.Xml; @@ -1077,6 +1078,5 @@ public static List GetUsedLanguages(Subtitle subtitle) } return list; } - } } diff --git a/src/Forms/Main.Designer.cs b/src/Forms/Main.Designer.cs index 52caabc5a3..8bff935ff7 100644 --- a/src/Forms/Main.Designer.cs +++ b/src/Forms/Main.Designer.cs @@ -57,6 +57,7 @@ private void InitializeComponent() this.toolStripButtonRemoveTextForHi = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonVisualSync = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonSpellCheck = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonNetflixQualityCheck = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonSettings = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparatorHelp = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButtonHelp = new System.Windows.Forms.ToolStripButton(); @@ -188,6 +189,7 @@ private void InitializeComponent() this.toolStripSeparatorAscOrDesc = new System.Windows.Forms.ToolStripSeparator(); this.AscendingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.descendingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.netflixQualityCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItemMakeEmptyFromCurrent = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemBatchConvert = new System.Windows.Forms.ToolStripMenuItem(); @@ -579,6 +581,7 @@ private void InitializeComponent() this.toolStripButtonRemoveTextForHi, this.toolStripButtonVisualSync, this.toolStripButtonSpellCheck, + this.toolStripButtonNetflixQualityCheck, this.toolStripButtonSettings, this.toolStripSeparatorHelp, this.toolStripButtonHelp, @@ -738,6 +741,17 @@ private void InitializeComponent() this.toolStripButtonSpellCheck.Text = "Spell check"; this.toolStripButtonSpellCheck.Click += new System.EventHandler(this.ToolStripButtonSpellCheckClick); // + // toolStripButtonNetflixQualityCheck + // + this.toolStripButtonNetflixQualityCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonNetflixQualityCheck.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonNetflixQualityCheck.Image"))); + this.toolStripButtonNetflixQualityCheck.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonNetflixQualityCheck.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonNetflixQualityCheck.Name = "toolStripButtonNetflixQualityCheck"; + this.toolStripButtonNetflixQualityCheck.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonNetflixQualityCheck.Text = "Netflix quality check"; + this.toolStripButtonNetflixQualityCheck.Click += new System.EventHandler(this.toolStripButtonNetflixGlyphCheck_Click); + // // toolStripButtonSettings // this.toolStripButtonSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; @@ -1595,6 +1609,7 @@ private void InitializeComponent() this.toolStripMenuItemAutoSplitLongLines, this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem, this.toolStripMenuItem1, + this.netflixQualityCheckToolStripMenuItem, this.toolStripSeparator23, this.toolStripMenuItemMakeEmptyFromCurrent, this.toolStripMenuItemBatchConvert, @@ -1820,6 +1835,13 @@ private void InitializeComponent() this.descendingToolStripMenuItem.Text = "Descending"; this.descendingToolStripMenuItem.Click += new System.EventHandler(this.descendingToolStripMenuItem_Click); // + // netflixQualityCheckToolStripMenuItem + // + this.netflixQualityCheckToolStripMenuItem.Name = "netflixQualityCheckToolStripMenuItem"; + this.netflixQualityCheckToolStripMenuItem.Size = new System.Drawing.Size(346, 22); + this.netflixQualityCheckToolStripMenuItem.Text = "Netflix quality check"; + this.netflixQualityCheckToolStripMenuItem.Click += new System.EventHandler(this.netflixGlyphCheckToolStripMenuItem_Click); + // // toolStripSeparator23 // this.toolStripSeparator23.Name = "toolStripSeparator23"; @@ -5075,6 +5097,9 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripButton toolStripButtonFixCommonErrors; private System.Windows.Forms.ToolStripMenuItem removeSceneChangeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem addSceneChangeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem netflixQualityCheckToolStripMenuItem; + private System.Windows.Forms.ToolStripButton toolStripButtonNetflixQualityCheck; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEdl; + } } \ No newline at end of file diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 706f37ea48..5cb1bd4a10 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -25,6 +25,8 @@ using System.Text.RegularExpressions; using System.Windows.Forms; using Nikse.SubtitleEdit.Core.SpellCheck; +using Nikse.SubtitleEdit.Core.NetflixQualityCheck; +using System.Runtime.InteropServices; namespace Nikse.SubtitleEdit.Forms { @@ -364,6 +366,7 @@ public Main() UpdateRecentFilesUI(); InitializeToolbar(); + UpdateNetflixGlyphCheckToolsVisibility(); UiUtil.InitializeSubtitleFont(textBoxSource); UiUtil.InitializeSubtitleFont(textBoxListViewText); UiUtil.InitializeSubtitleFont(textBoxListViewTextAlternate); @@ -386,8 +389,8 @@ public Main() audioVisualizer.ShowSpectrogram = Configuration.Settings.General.ShowSpectrogram; panelWaveformControls.Visible = Configuration.Settings.General.ShowAudioVisualizer; trackBarWaveformPosition.Visible = Configuration.Settings.General.ShowAudioVisualizer; - toolStripButtonToggleWaveform.Checked = Configuration.Settings.General.ShowAudioVisualizer; - toolStripButtonToggleVideo.Checked = Configuration.Settings.General.ShowVideoPlayer; + toolStripButtonToggleWaveform.Visible = Configuration.Settings.General.ShowAudioVisualizer; + toolStripButtonToggleVideo.Visible = Configuration.Settings.General.ShowVideoPlayer; if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) { @@ -1185,6 +1188,7 @@ private void InitializeLanguage() toolStripMenuItemAutoSplitLongLines.Text = _language.Menu.Tools.SplitLongLines; setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Text = _language.Menu.Tools.MinimumDisplayTimeBetweenParagraphs; toolStripMenuItem1.Text = _language.Menu.Tools.SortBy; + toolStripButtonNetflixQualityCheck.Text = _language.Menu.Tools.NetflixQualityCheck; sortNumberToolStripMenuItem.Text = _language.Menu.Tools.Number; sortStartTimeToolStripMenuItem.Text = _language.Menu.Tools.StartTime; @@ -1278,6 +1282,7 @@ private void InitializeLanguage() toolStripButtonRemoveTextForHi.ToolTipText = _language.Menu.ToolBar.RemoveTextForHi; toolStripButtonVisualSync.ToolTipText = _language.Menu.ToolBar.VisualSync; toolStripButtonSpellCheck.ToolTipText = _language.Menu.ToolBar.SpellCheck; + toolStripButtonNetflixQualityCheck.ToolTipText = _language.Menu.ToolBar.NetflixQualityCheck; toolStripButtonSettings.ToolTipText = _language.Menu.ToolBar.Settings; toolStripButtonHelp.ToolTipText = _language.Menu.ToolBar.Help; toolStripButtonToggleWaveform.ToolTipText = _language.Menu.ToolBar.ShowHideWaveform; @@ -3444,6 +3449,11 @@ private DialogResult SaveSubtitle(SubtitleFormat format) currentEncoding = Encoding.UTF8; } + if (format.GetType() == typeof(NetflixTimedText)) + { + NetflixGlyphCheck(false); + } + if (ModifierKeys == (Keys.Control | Keys.Shift)) allText = allText.Replace("\r\n", "\n"); @@ -3772,6 +3782,8 @@ private void ComboBoxSubtitleFormatsSelectedIndexChanged(object sender, EventArg } } ShowHideTextBasedFeatures(format); + + UpdateNetflixGlyphCheckToolsVisibility(); } private static List GetNuendoStyles() @@ -3848,7 +3860,7 @@ private void ShowSettings() { settings.Initialize(Icon, toolStripButtonFileNew.Image, toolStripButtonFileOpen.Image, toolStripButtonSave.Image, toolStripButtonSaveAs.Image, toolStripButtonFind.Image, toolStripButtonReplace.Image, toolStripButtonFixCommonErrors.Image, toolStripButtonRemoveTextForHi.Image, toolStripButtonVisualSync.Image, - toolStripButtonSpellCheck.Image, toolStripButtonSettings.Image, toolStripButtonHelp.Image); + toolStripButtonSpellCheck.Image, toolStripButtonNetflixQualityCheck.Image, toolStripButtonSettings.Image, toolStripButtonHelp.Image); settings.ShowDialog(this); } @@ -4065,6 +4077,7 @@ private void InitializeToolbar() TryLoadIcon(toolStripButtonRemoveTextForHi, "RemoveTextForHi"); TryLoadIcon(toolStripButtonVisualSync, "VisualSync"); TryLoadIcon(toolStripButtonSpellCheck, "SpellCheck"); + TryLoadIcon(toolStripButtonNetflixQualityCheck, "NetflixGlyphCheck"); TryLoadIcon(toolStripButtonSettings, "Settings"); TryLoadIcon(toolStripButtonHelp, "Help"); @@ -4082,6 +4095,7 @@ private void InitializeToolbar() toolStripButtonVisualSync.Visible = gs.ShowToolbarVisualSync; toolStripButtonSpellCheck.Visible = gs.ShowToolbarSpellCheck; + toolStripButtonNetflixQualityCheck.Visible = gs.ShowToolbarNetflixGlyphCheck; toolStripButtonSettings.Visible = gs.ShowToolbarSettings; toolStripButtonHelp.Visible = gs.ShowToolbarHelp; @@ -4095,7 +4109,10 @@ private void InitializeToolbar() toolStripSeparatorHelp.Visible = gs.ShowToolbarHelp; toolStrip1.Visible = gs.ShowToolbarNew || gs.ShowToolbarOpen || gs.ShowToolbarSave || gs.ShowToolbarSaveAs || gs.ShowToolbarFind || gs.ShowToolbarReplace || - gs.ShowToolbarFixCommonErrors || gs.ShowToolbarVisualSync || gs.ShowToolbarSpellCheck || gs.ShowToolbarSettings || gs.ShowToolbarHelp; + gs.ShowToolbarFixCommonErrors || gs.ShowToolbarVisualSync || gs.ShowToolbarSpellCheck || gs.ShowToolbarNetflixGlyphCheck || + gs.ShowToolbarSettings || gs.ShowToolbarHelp; + + UpdateNetflixGlyphCheckToolsVisibility(); } private void ToolStripButtonFileNewClick(object sender, EventArgs e) @@ -17889,6 +17906,8 @@ private void ToolStripMenuItemVideoDropDownClosed(object sender, EventArgs e) private void ToolsToolStripMenuItemDropDownOpening(object sender, EventArgs e) { + SubtitleFormat format = GetCurrentSubtitleFormat(); + if (_subtitle?.Paragraphs.Count > 0 && _networkSession == null) { toolStripSeparator23.Visible = true; @@ -17901,7 +17920,8 @@ private void ToolsToolStripMenuItemDropDownOpening(object sender, EventArgs e) toolStripMenuItemMakeEmptyFromCurrent.Visible = false; toolStripMenuItemShowOriginalInPreview.Checked = false; } - styleToolStripMenuItem.Visible = GetCurrentSubtitleFormat().HasStyleSupport; + + styleToolStripMenuItem.Visible = format.HasStyleSupport; } private void ContextMenuStripWaveformOpening(object sender, System.ComponentModel.CancelEventArgs e) @@ -20295,5 +20315,76 @@ private void MenuClosed(object sender, EventArgs e) IsMenuOpen = false; } + private void UpdateNetflixGlyphCheckToolsVisibility() + { + bool showTools = IsNetflixGlyphCheckAvailable(); + + netflixQualityCheckToolStripMenuItem.Visible = showTools; + toolStripButtonNetflixQualityCheck.Visible = showTools && Configuration.Settings.General.ShowToolbarNetflixGlyphCheck; + } + + private bool IsNetflixGlyphCheckAvailable() + { + SubtitleFormat format = GetCurrentSubtitleFormat(); + bool showTool = format.GetType() == typeof(TimedText10) || format.GetType() == typeof(NetflixTimedText); + return showTool; + } + + private void NetflixGlyphCheck(bool showSuccessMessage = true) + { + // Get subtitle + ReloadFromSourceView(); + string subtitle = _subtitle.ToText(GetCurrentSubtitleFormat()); + + // Check + NetflixQualityReportBuilder glyphCheckReport = new NetflixQualityReportBuilder(); + NetflixGlyphChecker glyphChecker = new NetflixGlyphChecker(); + glyphChecker.Check(_subtitle, glyphCheckReport); + + NetflixQualityReportBuilder whiteSpaceCheckReport = new NetflixQualityReportBuilder(); + NetflixWhiteSpaceChecker whiteSpaceChecker = new NetflixWhiteSpaceChecker(); + whiteSpaceChecker.Check(_subtitle, whiteSpaceCheckReport); + + string fileName = string.IsNullOrEmpty(_fileName) ? "untitledSubtitle" : Path.GetFileNameWithoutExtension(_fileName); + + List messages = new List(); + + if (!glyphCheckReport.IsEmpty) + { + string reportPath = Path.GetTempPath() + fileName + "_NetflixGlyphCheck.csv"; + File.WriteAllText(reportPath, glyphCheckReport.ExportCSV()); + messages.Add(string.Format(Configuration.Settings.Language.NetflixQualityCheck.GlyphCheckFailed, reportPath)); + } + else if (showSuccessMessage) + { + messages.Add(Configuration.Settings.Language.NetflixQualityCheck.GlyphCheckSuccessfull); + } + + if (!whiteSpaceCheckReport.IsEmpty) + { + string reportPath = Path.GetTempPath() + fileName + "_NetflixWhiteSpaceCheck.csv"; + File.WriteAllText(reportPath, whiteSpaceCheckReport.ExportCSV()); + messages.Add(string.Format(Configuration.Settings.Language.NetflixQualityCheck.WhiteSpaceCheckFailed, reportPath)); + } + else if (showSuccessMessage) + { + messages.Add(Configuration.Settings.Language.NetflixQualityCheck.WhiteSpaceCheckSuccessfull); + } + + if (messages.Count != 0) + { + MessageBox.Show(String.Join("\n\n", messages.ToArray())); + } + } + + private void netflixGlyphCheckToolStripMenuItem_Click(object sender, EventArgs e) + { + NetflixGlyphCheck(); + } + + private void toolStripButtonNetflixGlyphCheck_Click(object sender, EventArgs e) + { + NetflixGlyphCheck(); + } } } diff --git a/src/Forms/Main.resx b/src/Forms/Main.resx index cbca7898cd..5cad52b93a 100644 --- a/src/Forms/Main.resx +++ b/src/Forms/Main.resx @@ -370,31 +370,31 @@ iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWaSURBVFhHrVZ7TJNXFCfZlpmYkCVzy7LpnE6zuJD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gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAZgBIwGYASMBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAdgBIwHYASMBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/Forms/Settings.Designer.cs b/src/Forms/Settings.Designer.cs index 56b2cec5b6..82b0e97aa9 100644 --- a/src/Forms/Settings.Designer.cs +++ b/src/Forms/Settings.Designer.cs @@ -89,6 +89,9 @@ private void InitializeComponent() this.groupBox2 = new System.Windows.Forms.GroupBox(); this.checkBoxShowFrameRate = new System.Windows.Forms.CheckBox(); this.groupBoxShowToolBarButtons = new System.Windows.Forms.GroupBox(); + this.labelTBNetflixQualityCheck = new System.Windows.Forms.Label(); + this.pictureBoxNetflixQualityCheck = new System.Windows.Forms.PictureBox(); + this.checkBoxNetflixQualityCheck = new System.Windows.Forms.CheckBox(); this.labelTBRemoveTextForHi = new System.Windows.Forms.Label(); this.pictureBoxTBRemoveTextForHi = new System.Windows.Forms.PictureBox(); this.checkBoxTBRemoveTextForHi = new System.Windows.Forms.CheckBox(); @@ -332,6 +335,7 @@ private void InitializeComponent() this.tabPageToolBar.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBoxShowToolBarButtons.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHelp)).BeginInit(); @@ -1143,6 +1147,9 @@ private void InitializeComponent() // this.groupBoxShowToolBarButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBNetflixQualityCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxNetflixQualityCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxNetflixQualityCheck); this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBRemoveTextForHi); this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxTBRemoveTextForHi); this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxTBRemoveTextForHi); @@ -1186,6 +1193,33 @@ private void InitializeComponent() this.groupBoxShowToolBarButtons.TabStop = false; this.groupBoxShowToolBarButtons.Text = "Show toolbar buttons"; // + // labelTBNetflixQualityCheck + // + this.labelTBNetflixQualityCheck.AutoSize = true; + this.labelTBNetflixQualityCheck.Location = new System.Drawing.Point(636, 136); + this.labelTBNetflixQualityCheck.Name = "labelTBNetflixQualityCheck"; + this.labelTBNetflixQualityCheck.Size = new System.Drawing.Size(103, 13); + this.labelTBNetflixQualityCheck.TabIndex = 42; + this.labelTBNetflixQualityCheck.Text = "Netflix quality check"; + // + // pictureBoxNetflixQualityCheck + // + this.pictureBoxNetflixQualityCheck.Location = new System.Drawing.Point(649, 155); + this.pictureBoxNetflixQualityCheck.Name = "pictureBoxNetflixQualityCheck"; + this.pictureBoxNetflixQualityCheck.Size = new System.Drawing.Size(32, 32); + this.pictureBoxNetflixQualityCheck.TabIndex = 41; + this.pictureBoxNetflixQualityCheck.TabStop = false; + // + // checkBoxNetflixQualityCheck + // + this.checkBoxNetflixQualityCheck.AutoSize = true; + this.checkBoxNetflixQualityCheck.Location = new System.Drawing.Point(652, 195); + this.checkBoxNetflixQualityCheck.Name = "checkBoxNetflixQualityCheck"; + this.checkBoxNetflixQualityCheck.Size = new System.Drawing.Size(55, 17); + this.checkBoxNetflixQualityCheck.TabIndex = 40; + this.checkBoxNetflixQualityCheck.Text = "Visible"; + this.checkBoxNetflixQualityCheck.UseVisualStyleBackColor = true; + // // labelTBRemoveTextForHi // this.labelTBRemoveTextForHi.AutoSize = true; @@ -3848,6 +3882,7 @@ private void InitializeComponent() this.groupBox2.PerformLayout(); this.groupBoxShowToolBarButtons.ResumeLayout(false); this.groupBoxShowToolBarButtons.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHelp)).EndInit(); @@ -4227,5 +4262,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkBoxTBRemoveTextForHi; private System.Windows.Forms.NumericUpDown numericUpDownMaxNumberOfLines; private System.Windows.Forms.Label labelMaxLines; + private System.Windows.Forms.Label labelTBNetflixQualityCheck; + private System.Windows.Forms.PictureBox pictureBoxNetflixQualityCheck; + private System.Windows.Forms.CheckBox checkBoxNetflixQualityCheck; } } \ No newline at end of file diff --git a/src/Forms/Settings.cs b/src/Forms/Settings.cs index a4f3c5a314..671e1dcb4b 100644 --- a/src/Forms/Settings.cs +++ b/src/Forms/Settings.cs @@ -86,6 +86,7 @@ public Settings() checkBoxVisualSync.Checked = gs.ShowToolbarVisualSync; checkBoxSettings.Checked = gs.ShowToolbarSettings; checkBoxSpellCheck.Checked = gs.ShowToolbarSpellCheck; + checkBoxNetflixQualityCheck.Checked = gs.ShowToolbarNetflixGlyphCheck; checkBoxHelp.Checked = gs.ShowToolbarHelp; comboBoxFrameRate.Items.Add((23.976).ToString(CultureInfo.CurrentCulture)); @@ -254,6 +255,7 @@ public Settings() labelTBRemoveTextForHi.Text = language.RemoveTextForHi; labelTBVisualSync.Text = language.VisualSync; labelTBSpellCheck.Text = language.SpellCheck; + labelTBNetflixQualityCheck.Text = language.NetflixQualityCheck; labelTBSettings.Text = language.SettingsName; labelTBHelp.Text = language.Help; checkBoxToolbarNew.Text = Configuration.Settings.Language.General.Visible; @@ -266,6 +268,7 @@ public Settings() checkBoxTBRemoveTextForHi.Text = Configuration.Settings.Language.General.Visible; checkBoxVisualSync.Text = Configuration.Settings.Language.General.Visible; checkBoxSpellCheck.Text = Configuration.Settings.Language.General.Visible; + checkBoxNetflixQualityCheck.Text = Configuration.Settings.Language.General.Visible; checkBoxSettings.Text = Configuration.Settings.Language.General.Visible; checkBoxHelp.Text = Configuration.Settings.Language.General.Visible; @@ -939,7 +942,7 @@ private void InitializeWaveformsAndSpectrogramsFolderEmpty(LanguageStructure.Set } public void Initialize(Icon icon, Image newFile, Image openFile, Image saveFile, Image saveFileAs, Image find, Image replace, Image fixCommonErrors, Image removeTextForHi, - Image visualSync, Image spellCheck, Image settings, Image help) + Image visualSync, Image spellCheck, Image NetflixGlyphCheck, Image settings, Image help) { Icon = (Icon)icon.Clone(); pictureBoxNew.Image = (Image)newFile.Clone(); @@ -952,6 +955,7 @@ public void Initialize(Icon icon, Image newFile, Image openFile, Image saveFile, pictureBoxTBRemoveTextForHi.Image = (Image)removeTextForHi.Clone(); pictureBoxVisualSync.Image = (Image)visualSync.Clone(); pictureBoxSpellCheck.Image = (Image)spellCheck.Clone(); + pictureBoxNetflixQualityCheck.Image = (Image)NetflixGlyphCheck.Clone(); pictureBoxSettings.Image = (Image)settings.Clone(); pictureBoxHelp.Image = (Image)help.Clone(); } @@ -1034,6 +1038,7 @@ private void ButtonOkClick(object sender, EventArgs e) gs.ShowToolbarVisualSync = checkBoxVisualSync.Checked; gs.ShowToolbarSettings = checkBoxSettings.Checked; gs.ShowToolbarSpellCheck = checkBoxSpellCheck.Checked; + gs.ShowToolbarNetflixGlyphCheck = checkBoxNetflixQualityCheck.Checked; gs.ShowToolbarHelp = checkBoxHelp.Checked; gs.ShowFrameRate = checkBoxShowFrameRate.Checked; diff --git a/src/Test/Logic/NetflixQualityCheckTest.cs b/src/Test/Logic/NetflixQualityCheckTest.cs new file mode 100644 index 0000000000..5cc3fb2e7c --- /dev/null +++ b/src/Test/Logic/NetflixQualityCheckTest.cs @@ -0,0 +1,50 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.NetflixQualityCheck; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Test.Logic +{ + [TestClass] + public class NetflixQualityCheckTest + { + [TestMethod] + public void TestNetflixGlyphChecker() + { + var sub = new Subtitle(); + var p1 = new Paragraph("Lorem ipsum dolor sit௓ amet, consectetur adi௟piscing elit.", 0, 1000); + sub.Paragraphs.Add(p1); + + NetflixQualityReportBuilder reportBuilder = new NetflixQualityReportBuilder(); + NetflixGlyphChecker glyphChecker = new NetflixGlyphChecker(); + + glyphChecker.Check(sub, reportBuilder); + + Assert.AreEqual(2, reportBuilder.Records.Count); + Assert.AreEqual("or sit௓ amet", reportBuilder.Records[0].Context); + Assert.AreEqual("ur adi௟pisci", reportBuilder.Records[1].Context); + } + + [TestMethod] + public void TestNetflixWhiteSpaceChecker() + { + var sub = new Subtitle(); + var p1 = new Paragraph("Lorem ipsum dolor sit amet, consectetur\r\n\r\nadipiscing\n\r\nelit.", 0, 1000); + sub.Paragraphs.Add(p1); + + NetflixQualityReportBuilder reportBuilder = new NetflixQualityReportBuilder(); + NetflixWhiteSpaceChecker glyphChecker = new NetflixWhiteSpaceChecker(); + + glyphChecker.Check(sub, reportBuilder); + + Assert.AreEqual(4, reportBuilder.Records.Count); + Assert.AreEqual("Lorem ipsu", reportBuilder.Records[0].Context); + Assert.AreEqual(" dolor sit", reportBuilder.Records[1].Context); + Assert.AreEqual("ctetur\r\n\r\nad", reportBuilder.Records[2].Context); + Assert.AreEqual("iscing\n\r\neli", reportBuilder.Records[3].Context); + } + } +} diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index 66aa1da972..61c7d0c105 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -49,6 +49,7 @@ +