From 8a556f69c6935e0239ac801b3fc5f60acc9d6d51 Mon Sep 17 00:00:00 2001 From: Simeon Date: Fri, 4 Jan 2019 18:17:55 -0800 Subject: [PATCH] Turn on warnings as errors. (#43) Enable more warnings and fix ones that were easy. --- Directory.Build.props | 3 +-- LottieGen/Glob.cs | 2 ++ Toolkit.ruleset | 27 +++++++++++++------ source/Lottie/Instantiator.cs | 1 + source/Lottie/LottieVisualSource.cs | 19 ++++++------- source/LottieData/Animatable.cs | 5 ++-- source/LottieData/AssetCollection.cs | 1 + source/LottieData/GradientStop.cs | 1 + source/LottieData/HoldEasing.cs | 4 +-- source/LottieData/LayerCollection.cs | 3 +++ source/LottieData/LinearEasing.cs | 4 +-- .../LottieData/LottieCompositionValidator.cs | 1 + .../Serialization/LottieCompositionReader.cs | 3 ++- .../LottieToWinCompTranslator.cs | 9 ++++--- .../CodeGen/CSharpInstantiatorGenerator.cs | 5 ++-- .../CodeGen/CxInstantiatorGenerator.cs | 4 +-- .../CodeGen/InstantiatorGeneratorBase.cs | 6 +++-- source/WinCompData/CodeGen/NodeNamer.cs | 1 + .../Expressions/CubicBezierFunction2.cs | 2 +- source/WinCompData/Expressions/Expression.cs | 2 ++ source/WinCompData/Expressions/TypeAssert.cs | 2 +- source/WinCompData/Tools/ApiCompatibility.cs | 1 + source/WinCompData/Tools/Graph.cs | 1 + source/WinCompData/Tools/ObjectGraph.cs | 1 + source/WinCompData/Wui/Color.cs | 1 + 25 files changed, 71 insertions(+), 38 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bc6fb03..1473b78 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,8 +28,7 @@ False - - false + true 1591 diff --git a/LottieGen/Glob.cs b/LottieGen/Glob.cs index 2f058a0..476c87f 100644 --- a/LottieGen/Glob.cs +++ b/LottieGen/Glob.cs @@ -12,6 +12,8 @@ static class Glob /// /// Returns the files that match the given pattern. /// + /// A list of pairs identifying the path to each file, and a path relative to the deepest + /// non-wildcarded part of the input. internal static IEnumerable<(string path, string relativePath)> EnumerateFiles(string value) { // Break the pattern into non-wildcarded directory and the pattern to match. diff --git a/Toolkit.ruleset b/Toolkit.ruleset index 30956e6..110ffab 100644 --- a/Toolkit.ruleset +++ b/Toolkit.ruleset @@ -89,28 +89,39 @@ + - + - + + - + + + + + + + + + + + + - + + - - - - + \ No newline at end of file diff --git a/source/Lottie/Instantiator.cs b/source/Lottie/Instantiator.cs index 70e7175..157b0c7 100644 --- a/source/Lottie/Instantiator.cs +++ b/source/Lottie/Instantiator.cs @@ -39,6 +39,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie /// Creates a new instance of /// described by the given . /// + /// The . internal static Wc.Visual CreateVisual(Wc.Compositor compositor, Wd.Visual visual) { var converter = new Instantiator(compositor); diff --git a/source/Lottie/LottieVisualSource.cs b/source/Lottie/LottieVisualSource.cs index 59104d9..a6c77ba 100644 --- a/source/Lottie/LottieVisualSource.cs +++ b/source/Lottie/LottieVisualSource.cs @@ -39,13 +39,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie Uri _uriSource; ContentFactory _contentFactory; + /// + /// Gets the options for the . + /// // Optimize Lotties by default. Optimization takes a little longer but usually produces much // more efficient translations. The only reason someone would turn optimization off is if // the time to translate is too high, but in that case the Lottie is probably going to perform // so badly on the machine that it won't really be usable with our without optimization. - /// - /// Gets the options for the . - /// public static DependencyProperty OptionsProperty { get; } = RegisterDp(nameof(Options), LottieVisualOptions.Optimize); @@ -99,6 +99,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie /// /// Called by XAML to convert a string to an . /// + /// The for the given url. public static LottieVisualSource CreateFromString(string uri) { var uriUri = StringToUri(uri); @@ -138,10 +139,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie return LoadAsync(sourceUri == null ? null : new Loader(this, sourceUri)).AsAsyncAction(); } - // TODO: currently explicitly implemented interfaces are causing a problem with .NET Native. Make them implicit for now. /// /// Implements . /// + // TODO: currently explicitly implemented interfaces are causing a problem with .NET Native. Make them implicit for now. public event TypedEventHandler AnimatedVisualInvalidated { add @@ -159,14 +160,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie } } - // TODO: currently explicitly implemented interfaces are causing a problem with .NET Native. Make them implicit for now. - //bool IAnimatedVisualSource.TryCreateAnimatedVisual( /// /// Implements . /// /// The that can be used as a factory for the resulting . /// An optional object that may provide extra information about the result. /// An . + // TODO: currently explicitly implemented interfaces are causing a problem with .NET Native. Make them implicit for now. + //bool IAnimatedVisualSource.TryCreateAnimatedVisual( public IAnimatedVisual TryCreateAnimatedVisual( Compositor compositor, out object diagnostics) @@ -305,7 +306,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie } // Asynchronously loads WinCompData from a Lottie file. - internal async Task LoadAsync(LottieVisualOptions Options) + internal async Task LoadAsync(LottieVisualOptions options) { if (_uri == null && _storageFile == null) { @@ -315,10 +316,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie LottieVisualDiagnostics diagnostics = null; Stopwatch sw = null; - if (Options.HasFlag(LottieVisualOptions.IncludeDiagnostics)) + if (options.HasFlag(LottieVisualOptions.IncludeDiagnostics)) { sw = Stopwatch.StartNew(); - diagnostics = new LottieVisualDiagnostics { Options = Options }; + diagnostics = new LottieVisualDiagnostics { Options = options }; } var result = new ContentFactory(diagnostics); diff --git a/source/LottieData/Animatable.cs b/source/LottieData/Animatable.cs index a580d19..345359a 100644 --- a/source/LottieData/Animatable.cs +++ b/source/LottieData/Animatable.cs @@ -92,12 +92,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData public bool IsAnimated => _keyFrames.Length > 1; /// - /// Returns true if this value is always equal to the given value. + /// Returns true if this value is always equal to the given value. /// + /// true if this value is always equal to the given value. public bool AlwaysEquals(T value) => !IsAnimated && value.Equals(InitialValue); - // Not a great hash code because it ignore the KeyFrames, but quick. /// + // Not a great hash code because it ignore the KeyFrames, but quick. public override int GetHashCode() => InitialValue.GetHashCode(); /// diff --git a/source/LottieData/AssetCollection.cs b/source/LottieData/AssetCollection.cs index a68c1aa..32cdc4b 100644 --- a/source/LottieData/AssetCollection.cs +++ b/source/LottieData/AssetCollection.cs @@ -25,6 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData /// /// Returns the with the given id, or null if not found. /// + /// The with the given id, or null if not found. public Asset GetAssetById(string id) { if (id == null) diff --git a/source/LottieData/GradientStop.cs b/source/LottieData/GradientStop.cs index eccb610..62d8b72 100644 --- a/source/LottieData/GradientStop.cs +++ b/source/LottieData/GradientStop.cs @@ -44,6 +44,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData /// Returns the first gradient stop in a sequence that is a color. Opacity will always be /// set to 1. /// + /// The first gradient stop in the sequence. public static Color GetFirstColor(ReadOnlySpan gradientStops) { foreach (var stop in gradientStops) diff --git a/source/LottieData/HoldEasing.cs b/source/LottieData/HoldEasing.cs index a754d98..8f0eeab 100644 --- a/source/LottieData/HoldEasing.cs +++ b/source/LottieData/HoldEasing.cs @@ -24,15 +24,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData /// public override EasingType Type => EasingType.Hold; - // All SetpEeasings are equivalent. /// + // All HoldEasings are equivalent. public override int GetHashCode() => (int)Type; /// public override bool Equals(object obj) => Equals(obj as HoldEasing); - // All LinearEasings are equivalent. /// + // All HoldEasings are equivalent. public bool Equals(HoldEasing other) => other != null; /// diff --git a/source/LottieData/LayerCollection.cs b/source/LottieData/LayerCollection.cs index 46935fb..9731b38 100644 --- a/source/LottieData/LayerCollection.cs +++ b/source/LottieData/LayerCollection.cs @@ -35,11 +35,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData /// Returns the s in the in /// painting order. /// + /// The s in painting order. public IEnumerable GetLayersBottomToTop() => _layers; /// /// Returns the with the given id, or null if no matching is found. /// + /// The corresponding or null if does not match + /// a single in the collection. public Layer GetLayerById(int? id) { if (!id.HasValue) diff --git a/source/LottieData/LinearEasing.cs b/source/LottieData/LinearEasing.cs index dd57d10..3a49a25 100644 --- a/source/LottieData/LinearEasing.cs +++ b/source/LottieData/LinearEasing.cs @@ -23,15 +23,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData /// public override string ToString() => nameof(LinearEasing); - // All LinearEasings are equivalent. /// + // All LinearEasings are equivalent. public override int GetHashCode() => (int)Type; /// public override bool Equals(object obj) => Equals(obj as LinearEasing); - // All LinearEasings are equivalent. /// + // All LinearEasings are equivalent. public bool Equals(LinearEasing other) => other != null; } } diff --git a/source/LottieData/LottieCompositionValidator.cs b/source/LottieData/LottieCompositionValidator.cs index b1e18e1..b6499f8 100644 --- a/source/LottieData/LottieCompositionValidator.cs +++ b/source/LottieData/LottieCompositionValidator.cs @@ -28,6 +28,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData /// Validates the given against all of the validation rules. /// Returns a list of validation issues, or an empty list if no issues were found. /// + /// A list of the issues discovered during validation. public static (string Code, string Description)[] Validate(LottieComposition lottieComposition) { if (lottieComposition == null) diff --git a/source/LottieReader/Serialization/LottieCompositionReader.cs b/source/LottieReader/Serialization/LottieCompositionReader.cs index fdcd16b..fefb5dd 100644 --- a/source/LottieReader/Serialization/LottieCompositionReader.cs +++ b/source/LottieReader/Serialization/LottieCompositionReader.cs @@ -81,8 +81,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieData.Serialization } /// - /// Parses a Lottie file to create a . + /// Parses a Lottie file to create a . /// + /// A read from the json stream. public static LottieComposition ReadLottieCompositionFromJsonStream( Stream stream, Options options, diff --git a/source/LottieToWinComp/LottieToWinCompTranslator.cs b/source/LottieToWinComp/LottieToWinCompTranslator.cs index b451e3b..0146f1a 100644 --- a/source/LottieToWinComp/LottieToWinCompTranslator.cs +++ b/source/LottieToWinComp/LottieToWinCompTranslator.cs @@ -47,10 +47,11 @@ using TypeConstraint = Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions.T namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp { - // See: https://helpx.adobe.com/pdf/after_effects_reference.pdf for the After Effects semantics. /// /// Translates a to an equivalent . /// + /// See https://helpx.adobe.com/pdf/after_effects_reference.pdf"/> for the + /// After Effects semantics. #if PUBLIC public #endif @@ -124,8 +125,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp /// If true, throw an exception if translation issues are found. /// The that contains the translated Lottie. /// A list of issues that were encountered during the translation. + /// true if the was translated. public static bool TryTranslateLottieComposition( - LottieData.LottieComposition lottieComposition, + LottieComposition lottieComposition, bool strictTranslation, out Visual visual, out (string Code, string Description)[] translationIssues) => @@ -144,6 +146,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp /// Add descriptions to objects for comments on generated code. /// The that contains the translated Lottie. /// A list of issues that were encountered during the translation. + /// true if the was translated. public static bool TryTranslateLottieComposition( LottieComposition lottieComposition, bool strictTranslation, @@ -169,8 +172,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp return true; } - internal Optimizer Optimizer => _lottieDataOptimizer; - void Translate() { var context = new TranslationContext(_lc); diff --git a/source/WinCompData/CodeGen/CSharpInstantiatorGenerator.cs b/source/WinCompData/CodeGen/CSharpInstantiatorGenerator.cs index 17bd1cc..cc7d181 100644 --- a/source/WinCompData/CodeGen/CSharpInstantiatorGenerator.cs +++ b/source/WinCompData/CodeGen/CSharpInstantiatorGenerator.cs @@ -37,6 +37,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen /// Returns the C# code for a factory that will instantiate the given as a /// Windows.UI.Composition Visual. /// + /// The C# code. public static string CreateFactoryCode( string className, Visual rootVisual, @@ -55,8 +56,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen return generator.GenerateCode(className, width, height); } - // Called by the base class to write the start of the file (i.e. everything up to the body of the Instantiator class). /// + // Called by the base class to write the start of the file (i.e. everything up to the body of the Instantiator class). protected override void WriteFileStart(CodeBuilder builder, CodeGenInfo info) { if (info.RequiresWin2d) @@ -97,8 +98,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen builder.OpenScope(); } - // Called by the base class to write the end of the file (i.e. everything after the body of the Instantiator class). /// + // Called by the base class to write the end of the file (i.e. everything after the body of the Instantiator class). protected override void WriteFileEnd( CodeBuilder builder, CodeGenInfo info) diff --git a/source/WinCompData/CodeGen/CxInstantiatorGenerator.cs b/source/WinCompData/CodeGen/CxInstantiatorGenerator.cs index c6ebac0..4bb47c7 100644 --- a/source/WinCompData/CodeGen/CxInstantiatorGenerator.cs +++ b/source/WinCompData/CodeGen/CxInstantiatorGenerator.cs @@ -88,8 +88,8 @@ public: }}"; } - // Called by the base class to write the start of the file (i.e. everything up to the body of the Instantiator class). /// + // Called by the base class to write the start of the file (i.e. everything up to the body of the Instantiator class). protected override void WriteFileStart( CodeBuilder builder, CodeGenInfo info) @@ -144,8 +144,8 @@ public: builder.WriteLine("ComPtr _d2dFactory;"); } - // Called by the base class to write the end of the file (i.e. everything after the body of the Instantiator class). /// + // Called by the base class to write the end of the file (i.e. everything after the body of the Instantiator class). protected override void WriteFileEnd( CodeBuilder builder, CodeGenInfo info) diff --git a/source/WinCompData/CodeGen/InstantiatorGeneratorBase.cs b/source/WinCompData/CodeGen/InstantiatorGeneratorBase.cs index d6df308..b64f04b 100644 --- a/source/WinCompData/CodeGen/InstantiatorGeneratorBase.cs +++ b/source/WinCompData/CodeGen/InstantiatorGeneratorBase.cs @@ -133,6 +133,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen /// as C# and C++. /// Returns null on failure. /// + /// A name, or null. public static string TrySynthesizeClassName(string name) { if (string.IsNullOrWhiteSpace(name)) @@ -280,6 +281,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen /// /// Call this to generate the code. Returns a string containing the generated code. /// + /// The code. protected string GenerateCode( string className, float width, @@ -344,6 +346,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen /// /// Returns the code to call the factory for the given object. /// + /// The code to call the factory for the given object. protected string CallFactoryFor(CanvasGeometry obj) { return CallFactoryFromFor(_currentObjectFactoryNode, obj); @@ -352,8 +355,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen // Returns the code to call the factory for the given node from the given node. string CallFactoryFromFor(ObjectData callerNode, ObjectData calleeNode) { - string result; - if (callerNode.CallFactoryFromForCache.TryGetValue(calleeNode, out result)) + if (callerNode.CallFactoryFromForCache.TryGetValue(calleeNode, out string result)) { // Return the factory from the cache. return result; diff --git a/source/WinCompData/CodeGen/NodeNamer.cs b/source/WinCompData/CodeGen/NodeNamer.cs index 2eaafcc..b339f08 100644 --- a/source/WinCompData/CodeGen/NodeNamer.cs +++ b/source/WinCompData/CodeGen/NodeNamer.cs @@ -26,6 +26,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.CodeGen /// Takes a list of nodes and generates unique names for them. Returns a list of node + name pairs. /// The names are chosen to be descriptive and usable in code generation. /// + /// A lot of node + name pairs usable in code generation. public static IEnumerable<(TNode, string)> GenerateNodeNames(IEnumerable nodes) { var nodesByTypeName = new Dictionary>(); diff --git a/source/WinCompData/Expressions/CubicBezierFunction2.cs b/source/WinCompData/Expressions/CubicBezierFunction2.cs index cd1bf3e..bbb68e4 100644 --- a/source/WinCompData/Expressions/CubicBezierFunction2.cs +++ b/source/WinCompData/Expressions/CubicBezierFunction2.cs @@ -135,8 +135,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions } } - // (1-t)^3P0 + 3(1-t)^2tP1 + 3(1-t)t^2P2 + t^3P3 /// + // (1-t)^3P0 + 3(1-t)^2tP1 + 3(1-t)t^2P2 + t^3P3 protected override Expression Simplify() { var oneMinusT = Subtract(Scalar(1), _t); diff --git a/source/WinCompData/Expressions/Expression.cs b/source/WinCompData/Expressions/Expression.cs index 8f5c44d..11de624 100644 --- a/source/WinCompData/Expressions/Expression.cs +++ b/source/WinCompData/Expressions/Expression.cs @@ -115,11 +115,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions /// /// Returns an equivalent expression, simplified if possible. /// + /// An equivalent expression, simplified if possible. protected abstract Expression Simplify(); /// /// Returns the expression as a string for use by WinComp animations. /// + /// The exression as a string suitable for use in the Composition expression animation APIs. protected abstract string CreateExpressionString(); protected static string Parenthesize(Expression expression) => diff --git a/source/WinCompData/Expressions/TypeAssert.cs b/source/WinCompData/Expressions/TypeAssert.cs index c6336b7..40159c0 100644 --- a/source/WinCompData/Expressions/TypeAssert.cs +++ b/source/WinCompData/Expressions/TypeAssert.cs @@ -24,8 +24,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions /// protected override Expression Simplify() => this; - // There is no syntax for a type assert, so just return the child syntax. /// + // There is no syntax for a type assert, so just return the child syntax. protected override string CreateExpressionString() => _child.ToString(); /// diff --git a/source/WinCompData/Tools/ApiCompatibility.cs b/source/WinCompData/Tools/ApiCompatibility.cs index 3ecb0ad..d811253 100644 --- a/source/WinCompData/Tools/ApiCompatibility.cs +++ b/source/WinCompData/Tools/ApiCompatibility.cs @@ -22,6 +22,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Tools /// /// Analyzes the given tree and returns information about its compatibility with a runtime. /// + /// An object with properties describing the compatibility requirements of the tree. public static ApiCompatibility Analyze(CompositionObject graphRoot) { // Always require CompostionGeometryClip - this ensures that we are never compatible with diff --git a/source/WinCompData/Tools/Graph.cs b/source/WinCompData/Tools/Graph.cs index a06c9da..113e051 100644 --- a/source/WinCompData/Tools/Graph.cs +++ b/source/WinCompData/Tools/Graph.cs @@ -20,6 +20,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Tools /// /// Returns the graph of nodes reachable from the given root. /// + /// A from the given Composition tree. public static ObjectGraph FromCompositionObject(CompositionObject root, bool includeVertices) => ObjectGraph.FromCompositionObject(root, includeVertices); diff --git a/source/WinCompData/Tools/ObjectGraph.cs b/source/WinCompData/Tools/ObjectGraph.cs index 5f5d98b..3bc4f0d 100644 --- a/source/WinCompData/Tools/ObjectGraph.cs +++ b/source/WinCompData/Tools/ObjectGraph.cs @@ -34,6 +34,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Tools /// /// Returns the graph of nodes reachable from the given root. /// + /// A for the given Composition tree. public static new ObjectGraph FromCompositionObject(CompositionObject root, bool includeVertices) { var result = new ObjectGraph(includeVertices); diff --git a/source/WinCompData/Wui/Color.cs b/source/WinCompData/Wui/Color.cs index e556149..969d497 100644 --- a/source/WinCompData/Wui/Color.cs +++ b/source/WinCompData/Wui/Color.cs @@ -77,6 +77,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Wui /// /// Attempts to get the friendly name for this color. /// + /// true if a friendly name was returned. public bool TryGetFriendlyName(out string name) { name = GetFriendlyName(A, R, G, B);