Refresh annotations source code and make attributes internal

--- _Src/Container/Properties/Annotations.cs
+++ _Src/Container/Properties/Annotations.cs
@@ -1,94 +1,270 @@
-using System;
+/* MIT License
+
+Copyright (c) 2016 JetBrains http://www.jetbrains.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. */
+
+using System;
+// ReSharper disable UnusedType.Global
+// ReSharper disable CheckNamespace

 #pragma warning disable 1591
 // ReSharper disable UnusedMember.Global
-// ReSharper disable UnusedParameter.Local
 // ReSharper disable MemberCanBePrivate.Global
 // ReSharper disable UnusedAutoPropertyAccessor.Global
 // ReSharper disable IntroduceOptionalParameters.Global
 // ReSharper disable MemberCanBeProtected.Global
 // ReSharper disable InconsistentNaming
-// ReSharper disable CheckNamespace

 namespace JetBrains.Annotations
 {
   ///
   /// Indicates that the value of the marked element could be <c>null</c> sometimes,
-  /// so the check for <c>null</c> is necessary before its usage
-  ///
-  /// <example>
-  /// [CanBeNull] public object Test() { return null; }
-  /// public void UseTest() {
+  /// so checking for <c>null</c> is required before its usage.
+  ///
+  /// <example>
+  /// [CanBeNull] object Test() => null;
+  ///
+  /// void UseTest() {
   ///   var p = Test();
   ///   var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
   /// }
   /// </example>
   [AttributeUsage(
-    AttributeTargets.Method | AttributeTargets.Parameter |
-    AttributeTargets.Property | AttributeTargets.Delegate |
-    AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
-  public sealed class CanBeNullAttribute : Attribute { }
-
-  ///
-  /// Indicates that the value of the marked element could never be <c>null</c>
-  ///
-  /// <example>
-  /// [NotNull] public object Foo() {
+    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
+    AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
+    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
+internal sealed class CanBeNullAttribute : Attribute { }
+
+  ///
+  /// Indicates that the value of the marked element can never be <c>null</c>.
+  ///
+  /// <example>
+  /// [NotNull] object Foo() {
   ///   return null; // Warning: Possible 'null' assignment
   /// }
   /// </example>
   [AttributeUsage(
-    AttributeTargets.Method | AttributeTargets.Parameter |
-    AttributeTargets.Property | AttributeTargets.Delegate |
-    AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
-  public sealed class NotNullAttribute : Attribute { }
-
-  ///
-  /// Indicates that the marked method builds string by format pattern and (optional) arguments.
-  /// Parameter, which contains format string, should be given in constructor. The format string
-  /// should be in <see cref="string.Format(IFormatProvider,string,object[])"/>-like form
+    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
+    AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
+    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
+internal sealed class NotNullAttribute : Attribute { }
+
+  ///
+  /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
+  /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
+  /// or of the Lazy.Value property can never be null.
+  ///
+  /// <example>
+  /// public void Foo([ItemNotNull]List<string> books)
+  /// {
+  ///   foreach (var book in books) {
+  ///     if (book != null) // Warning: Expression is always true
+  ///      Console.WriteLine(book.ToUpper());
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(
+    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
+    AttributeTargets.Delegate | AttributeTargets.Field)]
+internal sealed class ItemNotNullAttribute : Attribute { }
+
+  ///
+  /// Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task
+  /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
+  /// or of the Lazy.Value property can be null.
+  ///
+  /// <example>
+  /// public void Foo([ItemCanBeNull]List<string> books)
+  /// {
+  ///   foreach (var book in books)
+  ///   {
+  ///     // Warning: Possible 'System.NullReferenceException'
+  ///     Console.WriteLine(book.ToUpper());
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(
+    AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
+    AttributeTargets.Delegate | AttributeTargets.Field)]
+internal sealed class ItemCanBeNullAttribute : Attribute { }
+
+  ///
+  /// Indicates that the marked method builds string by the format pattern and (optional) arguments.
+  /// The parameter, which contains the format string, should be given in the constructor. The format string
+  /// should be in <see cref="string.Format(IFormatProvider,string,object[])"/>-like form.
   ///
   /// <example>
   /// [StringFormatMethod("message")]
-  /// public void ShowError(string message, params object[] args) { /* do something */ }
-  /// public void Foo() {
+  /// void ShowError(string message, params object[] args) { /* do something */ }
+  ///
+  /// void Foo() {
   ///   ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
   /// }
   /// </example>
   [AttributeUsage(
-    AttributeTargets.Constructor | AttributeTargets.Method,
-    AllowMultiple = false, Inherited = true)]
-  public sealed class StringFormatMethodAttribute : Attribute
+    AttributeTargets.Constructor | AttributeTargets.Method |
+    AttributeTargets.Property | AttributeTargets.Delegate)]
+internal sealed class StringFormatMethodAttribute : Attribute
   {
     /// <param name="formatParameterName">
-    /// Specifies which parameter of an annotated method should be treated as format-string
+    /// Specifies which parameter of an annotated method should be treated as the format string
     /// </param>
-    public StringFormatMethodAttribute(string formatParameterName)
+    public StringFormatMethodAttribute([NotNull] string formatParameterName)
     {
       FormatParameterName = formatParameterName;
     }

-    public string FormatParameterName { get; private set; }
-  }
-
-  ///
-  /// Indicates that the function argument should be string literal and match one
+    [NotNull] public string FormatParameterName { get; }
+  }
+
+  ///
+  /// Indicates that the marked parameter is a message template where placeholders are to be replaced by the following arguments
+  /// in the order in which they appear
+  ///
+  /// <example>
+  /// void LogInfo([StructuredMessageTemplate]string message, params object[] args) { /* do something */ }
+  ///
+  /// void Foo() {
+  ///   LogInfo("User created: {username}"); // Warning: Non-existing argument in format string
+  /// }
+  /// </example>
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class StructuredMessageTemplateAttribute : Attribute {}
+
+  ///
+  /// Use this annotation to specify a type that contains static or const fields
+  /// with values for the annotated property/field/parameter.
+  /// The specified type will be used to improve completion suggestions.
+  ///
+  /// <example>
+  /// namespace TestNamespace
+  /// {
+  ///   public class Constants
+  ///   {
+  ///     public static int INT_CONST = 1;
+  ///     public const string STRING_CONST = "1";
+  ///   }
+  ///
+  ///   public class Class1
+  ///   {
+  ///     [ValueProvider("TestNamespace.Constants")] public int myField;
+  ///     public void Foo([ValueProvider("TestNamespace.Constants")] string str) { }
+  ///
+  ///     public void Test()
+  ///     {
+  ///       Foo(/*try completion here*/);//
+  ///       myField = /*try completion here*/
+  ///     }
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(
+    AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field,
+    AllowMultiple = true)]
+internal sealed class ValueProviderAttribute : Attribute
+  {
+    public ValueProviderAttribute([NotNull] string name)
+    {
+      Name = name;
+    }
+
+    [NotNull] public string Name { get; }
+  }
+
+  ///
+  /// Indicates that the integral value falls into the specified interval.
+  /// It's allowed to specify multiple non-intersecting intervals.
+  /// Values of interval boundaries are inclusive.
+  ///
+  /// <example>
+  /// void Foo([ValueRange(0, 100)] int value) {
+  ///   if (value == -1) { // Warning: Expression is always 'false'
+  ///     ...
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(
+    AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
+    AttributeTargets.Method | AttributeTargets.Delegate,
+    AllowMultiple = true)]
+internal sealed class ValueRangeAttribute : Attribute
+  {
+    public object From { get; }
+    public object To { get; }
+
+    public ValueRangeAttribute(long from, long to)
+    {
+      From = from;
+      To = to;
+    }
+
+    public ValueRangeAttribute(ulong from, ulong to)
+    {
+      From = from;
+      To = to;
+    }
+
+    public ValueRangeAttribute(long value)
+    {
+      From = To = value;
+    }
+
+    public ValueRangeAttribute(ulong value)
+    {
+      From = To = value;
+    }
+  }
+
+  ///
+  /// Indicates that the integral value never falls below zero.
+  ///
+  /// <example>
+  /// void Foo([NonNegativeValue] int value) {
+  ///   if (value == -1) { // Warning: Expression is always 'false'
+  ///     ...
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(
+    AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property |
+    AttributeTargets.Method | AttributeTargets.Delegate)]
+internal sealed class NonNegativeValueAttribute : Attribute { }
+
+  ///
+  /// Indicates that the function argument should be a string literal and match one
   /// of the parameters of the caller function. For example, ReSharper annotates
-  /// the parameter of <see cref="System.ArgumentNullException"/>
-  ///
-  /// <example>
-  /// public void Foo(string param) {
+  /// the parameter of <see cref="System.ArgumentNullException"/>.
+  ///
+  /// <example>
+  /// void Foo(string param) {
   ///   if (param == null)
   ///     throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
   /// }
   /// </example>
-  [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
-  public sealed class InvokerParameterNameAttribute : Attribute { }
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class InvokerParameterNameAttribute : Attribute { }

   ///
   /// Indicates that the method is contained in a type that implements
-  /// <see cref="System.ComponentModel.INotifyPropertyChanged"/> interface
-  /// and this method is used to notify that some property value changed
+  /// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
+  /// is used to notify that some property value changed.
   ///
   /// <remarks>
   /// The method should be non-static and conform to one of the supported signatures:
@@ -103,10 +279,12 @@
   /// <example>
   /// public class Foo : INotifyPropertyChanged {
   ///   public event PropertyChangedEventHandler PropertyChanged;
+  ///
   ///   [NotifyPropertyChangedInvocator]
   ///   protected virtual void NotifyChanged(string propertyName) { ... }
   ///
-  ///   private string _name;
+  ///   string _name;
+  ///
   ///   public string Name {
   ///     get { return _name; }
   ///     set { _name = value; NotifyChanged("LastName"); /* Warning */ }
@@ -121,20 +299,20 @@
   /// <item><c>SetProperty(ref myField, value, "Property")</c></item>
   /// </list>
   /// </example>
-  [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
-  public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
   {
     public NotifyPropertyChangedInvocatorAttribute() { }
-    public NotifyPropertyChangedInvocatorAttribute(string parameterName)
+    public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
     {
       ParameterName = parameterName;
     }

-    public string ParameterName { get; private set; }
-  }
-
-  ///
-  /// Describes dependency between method input and output
+    [CanBeNull] public string ParameterName { get; }
+  }
+
+  ///
+  /// Describes dependency between method input and output.
   ///
   /// <syntax>
   ///
Function Definition Table syntax:

@@ -145,38 +323,40 @@
   /// <item>Output   ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
   /// <item>Value    ::= true | false | null | notnull | canbenull</item>
   /// </list>
-  /// If method has single input parameter, it's name could be omitted.

-  /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same)
-  /// for method output means that the methos doesn't return normally.

-  /// <c>canbenull</c> annotation is only applicable for output parameters.

-  /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row,
-  /// or use single attribute with rows separated by semicolon.

+  /// If the method has a single input parameter, its name could be omitted.

+  /// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for the method output
+  /// means that the method doesn't return normally (throws or terminates the process).

+  /// Value <c>canbenull</c> is only applicable for output parameters.

+  /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
+  /// with rows separated by the semicolon. There is no notion of order rows, all rows are checked
+  /// for applicability and applied per each program state tracked by the analysis engine.

   /// </syntax>
   /// <examples><list>
   /// <item>
-  /// [ContractAnnotation("=> halt")]
+  /// [ContractAnnotation("=> halt")]
   /// public void TerminationMethod()
   /// </item>
   /// <item>
-  /// [ContractAnnotation("halt <= condition: false")]
-  /// public void Assert(bool condition, string text) // regular assertion method
+  /// [ContractAnnotation("null <= param:null")] // reverse condition syntax
+  /// public string GetName(string surname)
   /// </item>
   /// <item>
-  /// [ContractAnnotation("s:null => true")]
+  /// [ContractAnnotation("s:null => true")]
   /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
   /// </item>
   /// <item>
-  /// // A method that returns null if the parameter is null, and not null if the parameter is not null
-  /// [ContractAnnotation("null => null; notnull => notnull")]
-  /// public object Transform(object data)
+  /// // A method that returns null if the parameter is null,
+  /// // and not null if the parameter is not null
+  /// [ContractAnnotation("null => null; notnull => notnull")]
+  /// public object Transform(object data)
   /// </item>
   /// <item>
-  /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")]
+  /// [ContractAnnotation("=> true, result: notnull; => false, result: null")]
   /// public bool TryParse(string s, out Person result)
   /// </item>
   /// </list></examples>
-  [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
-  public sealed class ContractAnnotationAttribute : Attribute
+  [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+internal sealed class ContractAnnotationAttribute : Attribute
   {
     public ContractAnnotationAttribute([NotNull] string contract)
       : this(contract, false) { }
@@ -187,29 +367,31 @@
       ForceFullStates = forceFullStates;
     }

-    public string Contract { get; private set; }
-    public bool ForceFullStates { get; private set; }
-  }
-
-  ///
-  /// Indicates that marked element should be localized or not
+    [NotNull] public string Contract { get; }
+
+    public bool ForceFullStates { get; }
+  }
+
+  ///
+  /// Indicates whether the marked element should be localized.
   ///
   /// <example>
   /// [LocalizationRequiredAttribute(true)]
-  /// public class Foo {
-  ///   private string str = "my string"; // Warning: Localizable string
-  /// }
-  /// </example>
-  [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
-  public sealed class LocalizationRequiredAttribute : Attribute
+  /// class Foo {
+  ///   string str = "my string"; // Warning: Localizable string
+  /// }
+  /// </example>
+  [AttributeUsage(AttributeTargets.All)]
+internal sealed class LocalizationRequiredAttribute : Attribute
   {
     public LocalizationRequiredAttribute() : this(true) { }
+
     public LocalizationRequiredAttribute(bool required)
     {
       Required = required;
     }

-    public bool Required { get; private set; }
+    public bool Required { get; }
   }

   ///
@@ -221,8 +403,9 @@
   /// <example>
   /// [CannotApplyEqualityOperator]
   /// class NoEquality { }
+  ///
   /// class UsesNoEquality {
-  ///   public void Test() {
+  ///   void Test() {
   ///     var ca1 = new NoEquality();
   ///     var ca2 = new NoEquality();
   ///     if (ca1 != null) { // OK
@@ -231,10 +414,8 @@
   ///   }
   /// }
   /// </example>
-  [AttributeUsage(
-    AttributeTargets.Interface | AttributeTargets.Class |
-    AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
-  public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }
+  [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
+internal sealed class CannotApplyEqualityOperatorAttribute : Attribute { }

   ///
   /// When applied to a target attribute, specifies a requirement for any type marked
@@ -242,29 +423,44 @@
   ///
   /// <example>
   /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
-  /// public class ComponentAttribute : Attribute { }
+  /// class ComponentAttribute : Attribute { }
+  ///
   /// [Component] // ComponentAttribute requires implementing IComponent interface
-  /// public class MyComponent : IComponent { }
-  /// </example>
-  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
+  /// class MyComponent : IComponent { }
+  /// </example>
+  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
   [BaseTypeRequired(typeof(Attribute))]
-  public sealed class BaseTypeRequiredAttribute : Attribute
+internal sealed class BaseTypeRequiredAttribute : Attribute
   {
     public BaseTypeRequiredAttribute([NotNull] Type baseType)
     {
       BaseType = baseType;
     }

-    [NotNull] public Type BaseType { get; private set; }
-  }
-
-  ///
-  /// Indicates that the marked symbol is used implicitly
-  /// (e.g. via reflection, in external library), so this symbol
-  /// will not be marked as unused (as well as by other usage inspections)
-  ///
-  [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
-  public sealed class UsedImplicitlyAttribute : Attribute
+    [NotNull] public Type BaseType { get; }
+  }
+
+  ///
+  /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),
+  /// so this symbol will be ignored by usage-checking inspections.

+  /// You can use <see cref="ImplicitUseKindFlags"/> and <see cref="ImplicitUseTargetFlags"/>
+  /// to configure how this attribute is applied.
+  ///
+  /// <example>
+  /// [UsedImplicitly]
+  /// public class TypeConverter {}
+  ///
+  /// public class SummaryData
+  /// {
+  ///   [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
+  ///   public SummaryData() {}
+  /// }
+  ///
+  /// [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors | ImplicitUseTargetFlags.Default)]
+  /// public interface IService {}
+  /// </example>
+  [AttributeUsage(AttributeTargets.All)]
+internal sealed class UsedImplicitlyAttribute : Attribute
   {
     public UsedImplicitlyAttribute()
       : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
@@ -275,26 +471,27 @@
     public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
       : this(ImplicitUseKindFlags.Default, targetFlags) { }

-    public UsedImplicitlyAttribute(
-      ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
+    public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
     {
       UseKindFlags = useKindFlags;
       TargetFlags = targetFlags;
     }

-    public ImplicitUseKindFlags UseKindFlags { get; private set; }
-    public ImplicitUseTargetFlags TargetFlags { get; private set; }
-  }
-
-  ///
-  /// Should be used on attributes and causes ReSharper
-  /// to not mark symbols marked with such attributes as unused
-  /// (as well as by other usage inspections)
-  ///
-  [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
-  public sealed class MeansImplicitUseAttribute : Attribute
-  {
-    public MeansImplicitUseAttribute()
+    public ImplicitUseKindFlags UseKindFlags { get; }
+
+    public ImplicitUseTargetFlags TargetFlags { get; }
+  }
+
+  ///
+  /// Can be applied to attributes, type parameters, and parameters of a type assignable from <see cref="System.Type"/> .
+  /// When applied to an attribute, the decorated attribute behaves the same as <see cref="UsedImplicitlyAttribute"/>.
+  /// When applied to a type parameter or to a parameter of type <see cref="System.Type"/>,
+  /// indicates that the corresponding type is used implicitly.
+  ///
+  [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)]
+internal sealed class MeansImplicitUseAttribute : Attribute
+  {
+    public MeansImplicitUseAttribute()
       : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }

     public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
@@ -303,268 +500,456 @@
     public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
       : this(ImplicitUseKindFlags.Default, targetFlags) { }

-    public MeansImplicitUseAttribute(
-      ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
+    public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
     {
       UseKindFlags = useKindFlags;
       TargetFlags = targetFlags;
     }

-    [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; }
-    [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; }
-  }
-
+    [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; }
+
+    [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; }
+  }
+
+  ///
+  /// Specifies the details of implicitly used symbol when it is marked
+  /// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>.
+  ///
   [Flags]
-  public enum ImplicitUseKindFlags
+internal enum ImplicitUseKindFlags
   {
     Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
-    /// Only entity marked with attribute considered used
+    /// Only entity marked with attribute considered used.
     Access = 1,
-    /// Indicates implicit assignment to a member
+    /// Indicates implicit assignment to a member.
     Assign = 2,
     ///
     /// Indicates implicit instantiation of a type with fixed constructor signature.
     /// That means any unused constructor parameters won't be reported as such.
     ///
     InstantiatedWithFixedConstructorSignature = 4,
-    /// Indicates implicit instantiation of a type
+    /// Indicates implicit instantiation of a type.
     InstantiatedNoFixedConstructorSignature = 8,
   }

   ///
-  /// Specify what is considered used implicitly
-  /// when marked with <see cref="MeansImplicitUseAttribute"/>
-  /// or <see cref="UsedImplicitlyAttribute"/>
+  /// Specifies what is considered to be used implicitly when marked
+  /// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>.
   ///
   [Flags]
-  public enum ImplicitUseTargetFlags
+internal enum ImplicitUseTargetFlags
   {
     Default = Itself,
     Itself = 1,
-    /// Members of entity marked with attribute are considered used
+    /// Members of the type marked with the attribute are considered used.
     Members = 2,
-    /// Entity marked with attribute and all its members considered used
+    ///  Inherited entities are considered used.
+    WithInheritors = 4,
+    /// Entity marked with the attribute and all its members considered used.
     WithMembers = Itself | Members
   }

   ///
-  /// This attribute is intended to mark publicly available API
-  /// which should not be removed and so is treated as used
-  ///
-  [MeansImplicitUse]
-  public sealed class PublicAPIAttribute : Attribute
+  /// This attribute is intended to mark publicly available API,
+  /// which should not be removed and so is treated as used.
+  ///
+  [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
+  [AttributeUsage(AttributeTargets.All, Inherited = false)]
+internal sealed class PublicAPIAttribute : Attribute
   {
     public PublicAPIAttribute() { }
+
     public PublicAPIAttribute([NotNull] string comment)
     {
       Comment = comment;
     }

-    [NotNull] public string Comment { get; private set; }
-  }
-
-  ///
-  /// Tells code analysis engine if the parameter is completely handled
-  /// when the invoked method is on stack. If the parameter is a delegate,
-  /// indicates that delegate is executed while the method is executed.
-  /// If the parameter is an enumerable, indicates that it is enumerated
-  /// while the method is executed
-  ///
-  [AttributeUsage(AttributeTargets.Parameter, Inherited = true)]
-  public sealed class InstantHandleAttribute : Attribute { }
+    [CanBeNull] public string Comment { get; }
+  }
+
+  ///
+  /// Tells the code analysis engine if the parameter is completely handled when the invoked method is on stack.
+  /// If the parameter is a delegate, indicates that delegate is executed while the method is executed.
+  /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class InstantHandleAttribute : Attribute { }

   ///
   /// Indicates that a method does not make any observable state changes.
-  /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>
-  ///
-  /// <example>
-  /// [Pure] private int Multiply(int x, int y) { return x * y; }
-  /// public void Foo() {
-  ///   const int a = 2, b = 2;
-  ///   Multiply(a, b); // Waring: Return value of pure method is not used
-  /// }
-  /// </example>
-  [AttributeUsage(AttributeTargets.Method, Inherited = true)]
-  public sealed class PureAttribute : Attribute { }
-
-  ///
-  /// Indicates that a parameter is a path to a file or a folder
-  /// within a web project. Path can be relative or absolute,
-  /// starting from web root (~)
-  ///
+  /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
+  ///
+  /// <example>
+  /// [Pure] int Multiply(int x, int y) => x * y;
+  ///
+  /// void M() {
+  ///   Multiply(123, 42); // Warning: Return value of pure method is not used
+  /// }
+  /// </example>
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class PureAttribute : Attribute { }
+
+  ///
+  /// Indicates that the return value of the method invocation must be used.
+  ///
+  /// <remarks>
+  /// Methods decorated with this attribute (in contrast to pure methods) might change state,
+  /// but make no sense without using their return value.

+  /// Similarly to <see cref="PureAttribute"/>, this attribute
+  /// will help to detect usages of the method when the return value is not used.
+  /// Optionally, you can specify a message to use when showing warnings, e.g.
+  /// [MustUseReturnValue("Use the return value to...")].
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class MustUseReturnValueAttribute : Attribute
+  {
+    public MustUseReturnValueAttribute() { }
+
+    public MustUseReturnValueAttribute([NotNull] string justification)
+    {
+      Justification = justification;
+    }
+
+    [CanBeNull] public string Justification { get; }
+  }
+
+  ///
+  /// This annotation allows to enforce allocation-less usage patterns of delegates for performance-critical APIs.
+  /// When this annotation is applied to the parameter of delegate type, IDE checks the input argument of this parameter:
+  /// * When lambda expression or anonymous method is passed as an argument, IDE verifies that the passed closure
+  ///   has no captures of the containing local variables and the compiler is able to cache the delegate instance
+  ///   to avoid heap allocations. Otherwise the warning is produced.
+  /// * IDE warns when method name or local function name is passed as an argument as this always results
+  ///   in heap allocation of the delegate instance.
+  ///
+  /// <remarks>
+  /// In C# 9.0 code IDE would also suggest to annotate the anonymous function with 'static' modifier
+  /// to make use of the similar analysis provided by the language/compiler.
+  /// </remarks>
   [AttributeUsage(AttributeTargets.Parameter)]
-  public class PathReferenceAttribute : Attribute
+internal class RequireStaticDelegateAttribute : Attribute
+  {
+    public bool IsError { get; set; }
+  }
+
+  ///
+  /// Indicates the type member or parameter of some type, that should be used instead of all other ways
+  /// to get the value of that type. This annotation is useful when you have some "context" value evaluated
+  /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.
+  ///
+  /// <example>
+  /// class Foo {
+  ///   [ProvidesContext] IBarService _barService = ...;
+  ///
+  ///   void ProcessNode(INode node) {
+  ///     DoSomething(node, node.GetGlobalServices().Bar);
+  ///     //              ^ Warning: use value of '_barService' field
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(
+    AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |
+    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)]
+internal sealed class ProvidesContextAttribute : Attribute { }
+
+  ///
+  /// Indicates that a parameter is a path to a file or a folder within a web project.
+  /// Path can be relative or absolute, starting from web root (~).
+  ///
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class PathReferenceAttribute : Attribute
   {
     public PathReferenceAttribute() { }
-    public PathReferenceAttribute([PathReference] string basePath)
+
+    public PathReferenceAttribute([NotNull, PathReference] string basePath)
     {
       BasePath = basePath;
     }

-    [NotNull] public string BasePath { get; private set; }
-  }
-
-  // ASP.NET MVC attributes
-
-  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
-  public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
-  {
-    public AspMvcAreaMasterLocationFormatAttribute(string format) { }
-  }
-
-  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
-  public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
-  {
-    public AspMvcAreaPartialViewLocationFormatAttribute(string format) { }
-  }
-
-  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
-  public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
-  {
-    public AspMvcAreaViewLocationFormatAttribute(string format) { }
-  }
-
-  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
-  public sealed class AspMvcMasterLocationFormatAttribute : Attribute
-  {
-    public AspMvcMasterLocationFormatAttribute(string format) { }
-  }
-
-  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
-  public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
-  {
-    public AspMvcPartialViewLocationFormatAttribute(string format) { }
-  }
-
-  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
-  public sealed class AspMvcViewLocationFormatAttribute : Attribute
-  {
-    public AspMvcViewLocationFormatAttribute(string format) { }
-  }
-
+    [CanBeNull] public string BasePath { get; }
+  }
+
+  ///
+  /// An extension method marked with this attribute is processed by code completion
+  /// as a 'Source Template'. When the extension method is completed over some expression, its source code
+  /// is automatically expanded like a template at call site.
+  ///
+  /// <remarks>
+  /// Template method body can contain valid source code and/or special comments starting with '$'.
+  /// Text inside these comments is added as source code when the template is applied. Template parameters
+  /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
+  /// Use the <see cref="MacroAttribute"/> attribute to specify macros for parameters.
+  /// </remarks>
+  /// <example>
+  /// In this example, the 'forEach' method is a source template available over all values
+  /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
+  ///
+  /// [SourceTemplate]
+  /// public static void forEach<T>(this IEnumerable<T> xs) {
+  ///   foreach (var x in xs) {
+  ///      //$ $END$
+  ///   }
+  /// }
+  ///
+  /// </example>
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class SourceTemplateAttribute : Attribute { }
+
+  ///
+  /// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
+  ///
+  /// <remarks>
+  /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression
+  /// is defined in the <see cref="MacroAttribute.Expression"/> property. When applied on a method, the target
+  /// template parameter is defined in the <see cref="MacroAttribute.Target"/> property. To apply the macro silently
+  /// for the parameter, set the <see cref="MacroAttribute.Editable"/> property value = -1.
+  /// </remarks>
+  /// <example>
+  /// Applying the attribute on a source template method:
+  ///
+  /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
+  /// public static void forEach<T>(this IEnumerable<T> collection) {
+  ///   foreach (var item in collection) {
+  ///     //$ $END$
+  ///   }
+  /// }
+  ///
+  /// Applying the attribute on a template method parameter:
+  ///
+  /// [SourceTemplate]
+  /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
+  ///   /*$ var $x$Id = "$newguid$" + x.ToString();
+  ///   x.DoSomething($x$Id); */
+  /// }
+  ///
+  /// </example>
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]
+internal sealed class MacroAttribute : Attribute
+  {
+    ///
+    /// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
+    /// parameter when the template is expanded.
+    ///
+    [CanBeNull] public string Expression { get; set; }
+
+    ///
+    /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
+    ///
+    /// <remarks>
+    /// If the target parameter is used several times in the template, only one occurrence becomes editable;
+    /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,
+    /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
+    /// </remarks>
+    public int Editable { get; set; }
+
+    ///
+    /// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
+    /// <see cref="MacroAttribute"/> is applied on a template method.
+    ///
+    [CanBeNull] public string Target { get; set; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
+internal sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
+  {
+    public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
+    {
+      Format = format;
+    }
+
+    [NotNull] public string Format { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
+internal sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
+  {
+    public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
+    {
+      Format = format;
+    }
+
+    [NotNull] public string Format { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
+internal sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
+  {
+    public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
+    {
+      Format = format;
+    }
+
+    [NotNull] public string Format { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
+internal sealed class AspMvcMasterLocationFormatAttribute : Attribute
+  {
+    public AspMvcMasterLocationFormatAttribute([NotNull] string format)
+    {
+      Format = format;
+    }
+
+    [NotNull] public string Format { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
+internal sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
+  {
+    public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
+    {
+      Format = format;
+    }
+
+    [NotNull] public string Format { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
+internal sealed class AspMvcViewLocationFormatAttribute : Attribute
+  {
+    public AspMvcViewLocationFormatAttribute([NotNull] string format)
+    {
+      Format = format;
+    }
+
+    [NotNull] public string Format { get; }
+  }
+
   ///
   /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
   /// is an MVC action. If applied to a method, the MVC action name is calculated
   /// implicitly from the context. Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
-  public sealed class AspMvcActionAttribute : Attribute
+  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcActionAttribute : Attribute
   {
     public AspMvcActionAttribute() { }
+
     public AspMvcActionAttribute([NotNull] string anonymousProperty)
     {
       AnonymousProperty = anonymousProperty;
     }

-    [NotNull] public string AnonymousProperty { get; private set; }
-  }
-
-  ///
-  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
+    [CanBeNull] public string AnonymousProperty { get; }
+  }
+
+  ///
+  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area.
   /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>
+  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcAreaAttribute : Attribute
+  {
+    public AspMvcAreaAttribute() { }
+
+    public AspMvcAreaAttribute([NotNull] string anonymousProperty)
+    {
+      AnonymousProperty = anonymousProperty;
+    }
+
+    [CanBeNull] public string AnonymousProperty { get; }
+  }
+
+  ///
+  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
+  /// an MVC controller. If applied to a method, the MVC controller name is calculated
+  /// implicitly from the context. Use this attribute for custom wrappers similar to
+  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcControllerAttribute : Attribute
+  {
+    public AspMvcControllerAttribute() { }
+
+    public AspMvcControllerAttribute([NotNull] string anonymousProperty)
+    {
+      AnonymousProperty = anonymousProperty;
+    }
+
+    [CanBeNull] public string AnonymousProperty { get; }
+  }
+
+  ///
+  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute
+  /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcMasterAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute
+  /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
   ///
   [AttributeUsage(AttributeTargets.Parameter)]
-  public sealed class AspMvcAreaAttribute : PathReferenceAttribute
-  {
-    public AspMvcAreaAttribute() { }
-    public AspMvcAreaAttribute([NotNull] string anonymousProperty)
-    {
-      AnonymousProperty = anonymousProperty;
-    }
-
-    [NotNull] public string AnonymousProperty { get; private set; }
-  }
-
-  ///
-  /// ASP.NET MVC attribute. If applied to a parameter, indicates that
-  /// the parameter is an MVC controller. If applied to a method,
-  /// the MVC controller name is calculated implicitly from the context.
-  /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
-  public sealed class AspMvcControllerAttribute : Attribute
-  {
-    public AspMvcControllerAttribute() { }
-    public AspMvcControllerAttribute([NotNull] string anonymousProperty)
-    {
-      AnonymousProperty = anonymousProperty;
-    }
-
-    [NotNull] public string AnonymousProperty { get; private set; }
-  }
-
-  ///
-  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master.
+internal sealed class AspMvcModelTypeAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
+  /// partial view. If applied to a method, the MVC partial view name is calculated implicitly
+  /// from the context. Use this attribute for custom wrappers similar to
+  /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcPartialViewAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
+  ///
+  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+internal sealed class AspMvcSuppressViewErrorAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
   /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Controller.View(String, String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter)]
-  public sealed class AspMvcMasterAttribute : Attribute { }
-
-  ///
-  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type.
+  /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcDisplayTemplateAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template.
   /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Controller.View(String, Object)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter)]
-  public sealed class AspMvcModelTypeAttribute : Attribute { }
-
-  ///
-  /// ASP.NET MVC attribute. If applied to a parameter, indicates that
-  /// the parameter is an MVC partial view. If applied to a method,
-  /// the MVC partial view name is calculated implicitly from the context.
+  /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcEditorTemplateAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template.
   /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
-  public sealed class AspMvcPartialViewAttribute : PathReferenceAttribute { }
-
-  ///
-  /// ASP.NET MVC attribute. Allows disabling all inspections
-  /// for MVC views within a class or a method.
-  ///
-  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
-  public sealed class AspMvcSupressViewErrorAttribute : Attribute { }
-
-  ///
-  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
-  /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter)]
-  public sealed class AspMvcDisplayTemplateAttribute : Attribute { }
-
-  ///
-  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template.
-  /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter)]
-  public sealed class AspMvcEditorTemplateAttribute : Attribute { }
-
-  ///
-  /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
-  /// Use this attribute for custom wrappers similar to
-  /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter)]
-  public sealed class AspMvcTemplateAttribute : Attribute { }
+  /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcTemplateAttribute : Attribute { }

   ///
   /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
-  /// is an MVC view. If applied to a method, the MVC view name is calculated implicitly
+  /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly
   /// from the context. Use this attribute for custom wrappers similar to
-  /// <c>System.Web.Mvc.Controller.View(Object)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
-  public sealed class AspMvcViewAttribute : PathReferenceAttribute { }
+  /// <c>System.Web.Mvc.Controller.View(Object)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcViewAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
+  /// is an MVC view component name.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcViewComponentAttribute : Attribute { }
+
+  ///
+  /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
+  /// is an MVC view component view. If applied to a method, the MVC view component view name is default.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class AspMvcViewComponentViewAttribute : Attribute { }

   ///
   /// ASP.NET MVC attribute. When applied to a parameter of an attribute,
-  /// indicates that this parameter is an MVC action name
+  /// indicates that this parameter is an MVC action name.
   ///
   /// <example>
   /// [ActionName("Foo")]
@@ -574,42 +959,397 @@
   /// }
   /// </example>
   [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
-  public sealed class AspMvcActionSelectorAttribute : Attribute { }
-
+internal sealed class AspMvcActionSelectorAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
+internal sealed class HtmlElementAttributesAttribute : Attribute
+  {
+    public HtmlElementAttributesAttribute() { }
+
+    public HtmlElementAttributesAttribute([NotNull] string name)
+    {
+      Name = name;
+    }
+
+    [CanBeNull] public string Name { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class HtmlAttributeValueAttribute : Attribute
+  {
+    public HtmlAttributeValueAttribute([NotNull] string name)
+    {
+      Name = name;
+    }
+
+    [NotNull] public string Name { get; }
+  }
+
+  ///
+  /// Razor attribute. Indicates that the marked parameter or method is a Razor section.
+  /// Use this attribute for custom wrappers similar to
+  /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
+internal sealed class RazorSectionAttribute : Attribute { }
+
+  ///
+  /// Indicates how method, constructor invocation, or property access
+  /// over collection type affects the contents of the collection.
+  /// Use <see cref="CollectionAccessType"/> to specify the access type.
+  ///
+  /// <remarks>
+  /// Using this attribute only makes sense if all collection methods are marked with this attribute.
+  /// </remarks>
+  /// <example>
+  /// public class MyStringCollection : List<string>
+  /// {
+  ///   [CollectionAccess(CollectionAccessType.Read)]
+  ///   public string GetFirstString()
+  ///   {
+  ///     return this.ElementAt(0);
+  ///   }
+  /// }
+  /// class Test
+  /// {
+  ///   public void Foo()
+  ///   {
+  ///     // Warning: Contents of the collection is never updated
+  ///     var col = new MyStringCollection();
+  ///     string x = col.GetFirstString();
+  ///   }
+  /// }
+  /// </example>
+  [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)]
+internal sealed class CollectionAccessAttribute : Attribute
+  {
+    public CollectionAccessAttribute(CollectionAccessType collectionAccessType)
+    {
+      CollectionAccessType = collectionAccessType;
+    }
+
+    public CollectionAccessType CollectionAccessType { get; }
+  }
+
+  ///
+  /// Provides a value for the <see cref="CollectionAccessAttribute"/> to define
+  /// how the collection method invocation affects the contents of the collection.
+  ///
+  [Flags]
+internal enum CollectionAccessType
+  {
+    /// Method does not use or modify content of the collection.
+    None = 0,
+    /// Method only reads content of the collection but does not modify it.
+    Read = 1,
+    /// Method can change content of the collection but does not add new elements.
+    ModifyExistingContent = 2,
+    /// Method can add new elements to the collection.
+    UpdatedContent = ModifyExistingContent | 4
+  }
+
+  ///
+  /// Indicates that the marked method is assertion method, i.e. it halts the control flow if
+  /// one of the conditions is satisfied. To set the condition, mark one of the parameters with
+  /// <see cref="AssertionConditionAttribute"/> attribute.
+  ///
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class AssertionMethodAttribute : Attribute { }
+
+  ///
+  /// Indicates the condition parameter of the assertion method. The method itself should be
+  /// marked by <see cref="AssertionMethodAttribute"/> attribute. The mandatory argument of
+  /// the attribute is the assertion type.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class AssertionConditionAttribute : Attribute
+  {
+    public AssertionConditionAttribute(AssertionConditionType conditionType)
+    {
+      ConditionType = conditionType;
+    }
+
+    public AssertionConditionType ConditionType { get; }
+  }
+
+  ///
+  /// Specifies assertion type. If the assertion method argument satisfies the condition,
+  /// then the execution continues. Otherwise, execution is assumed to be halted.
+  ///
+internal enum AssertionConditionType
+  {
+    /// Marked parameter should be evaluated to true.
+    IS_TRUE = 0,
+    /// Marked parameter should be evaluated to false.
+    IS_FALSE = 1,
+    /// Marked parameter should be evaluated to null value.
+    IS_NULL = 2,
+    /// Marked parameter should be evaluated to not null value.
+    IS_NOT_NULL = 3,
+  }
+
+  ///
+  /// Indicates that the marked method unconditionally terminates control flow execution.
+  /// For example, it could unconditionally throw exception.
+  ///
+  [Obsolete("Use [ContractAnnotation('=> halt')] instead")]
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class TerminatesProgramAttribute : Attribute { }
+
+  ///
+  /// Indicates that the method is a pure LINQ method, with postponed enumeration (like Enumerable.Select,
+  /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters
+  /// of delegate type by analyzing LINQ method chains.
+  ///
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class LinqTunnelAttribute : Attribute { }
+
+  ///
+  /// Indicates that IEnumerable passed as a parameter is not enumerated.
+  /// Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection.
+  ///
+  /// <example>
+  /// static void ThrowIfNull<T>([NoEnumeration] T v, string n) where T : class
+  /// {
+  ///   // custom check for null but no enumeration
+  /// }
+  ///
+  /// void Foo(IEnumerable<string> values)
+  /// {
+  ///   ThrowIfNull(values, nameof(values));
+  ///   var x = values.ToList(); // No warnings about multiple enumeration
+  /// }
+  /// </example>
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class NoEnumerationAttribute : Attribute { }
+
+  ///
+  /// Indicates that the marked parameter, field, or property is a regular expression pattern.
+  ///
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class RegexPatternAttribute : Attribute { }
+
+  ///
+  /// Prevents the Member Reordering feature from tossing members of the marked class.
+  ///
+  /// <remarks>
+  /// The attribute must be mentioned in your member reordering patterns.
+  /// </remarks>
   [AttributeUsage(
-    AttributeTargets.Parameter | AttributeTargets.Property |
-    AttributeTargets.Field, Inherited = true)]
-  public sealed class HtmlElementAttributesAttribute : Attribute
-  {
-    public HtmlElementAttributesAttribute() { }
-    public HtmlElementAttributesAttribute([NotNull] string name)
+    AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]
+internal sealed class NoReorderAttribute : Attribute { }
+
+  ///
+  /// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated
+  /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
+  ///
+  [AttributeUsage(AttributeTargets.Class)]
+internal sealed class XamlItemsControlAttribute : Attribute { }
+
+  ///
+  /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that
+  /// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will
+  /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
+  ///
+  /// <remarks>
+  /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
+  /// marked with the <see cref="XamlItemsControlAttribute"/> attribute.
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Property)]
+internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute { }
+
+  ///
+  /// XAML attribute. Indicates the property of some <c>Style</c>-derived type, that
+  /// is used to style items of <c>ItemsControl</c>-derived type. This annotation will
+  /// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
+  ///
+  /// <remarks>
+  /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
+  /// marked with the <see cref="XamlItemsControlAttribute"/> attribute.
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Property)]
+internal sealed class XamlItemStyleOfItemsControlAttribute : Attribute { }
+
+  ///
+  /// XAML attribute. Indicates that DependencyProperty has <c>OneWay</c> binding mode by default.
+  ///
+  /// <remarks>
+  /// This attribute must be applied to DependencyProperty's CLR accessor property if it is present, to DependencyProperty descriptor field otherwise.
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class XamlOneWayBindingModeByDefaultAttribute : Attribute { }
+
+  ///
+  /// XAML attribute. Indicates that DependencyProperty has <c>TwoWay</c> binding mode by default.
+  ///
+  /// <remarks>
+  /// This attribute must be applied to DependencyProperty's CLR accessor property if it is present, to DependencyProperty descriptor field otherwise.
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class XamlTwoWayBindingModeByDefaultAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+internal sealed class AspChildControlTypeAttribute : Attribute
+  {
+    public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)
+    {
+      TagName = tagName;
+      ControlType = controlType;
+    }
+
+    [NotNull] public string TagName { get; }
+
+    [NotNull] public Type ControlType { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
+internal sealed class AspDataFieldAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
+internal sealed class AspDataFieldsAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Property)]
+internal sealed class AspMethodPropertyAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+internal sealed class AspRequiredAttributeAttribute : Attribute
+  {
+    public AspRequiredAttributeAttribute([NotNull] string attribute)
+    {
+      Attribute = attribute;
+    }
+
+    [NotNull] public string Attribute { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Property)]
+internal sealed class AspTypePropertyAttribute : Attribute
+  {
+    public bool CreateConstructorReferences { get; }
+
+    public AspTypePropertyAttribute(bool createConstructorReferences)
+    {
+      CreateConstructorReferences = createConstructorReferences;
+    }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+internal sealed class RazorImportNamespaceAttribute : Attribute
+  {
+    public RazorImportNamespaceAttribute([NotNull] string name)
     {
       Name = name;
     }

-    [NotNull] public string Name { get; private set; }
-  }
-
-  [AttributeUsage(
-    AttributeTargets.Parameter | AttributeTargets.Field |
-    AttributeTargets.Property, Inherited = true)]
-  public sealed class HtmlAttributeValueAttribute : Attribute
-  {
-    public HtmlAttributeValueAttribute([NotNull] string name)
-    {
-      Name = name;
-    }
-
-    [NotNull] public string Name { get; private set; }
-  }
-
-  // Razor attributes
-
-  ///
-  /// Razor attribute. Indicates that a parameter or a method is a Razor section.
-  /// Use this attribute for custom wrappers similar to
-  /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>
-  ///
-  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, Inherited = true)]
-  public sealed class RazorSectionAttribute : Attribute { }
-}+    [NotNull] public string Name { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+internal sealed class RazorInjectionAttribute : Attribute
+  {
+    public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)
+    {
+      Type = type;
+      FieldName = fieldName;
+    }
+
+    [NotNull] public string Type { get; }
+
+    [NotNull] public string FieldName { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+internal sealed class RazorDirectiveAttribute : Attribute
+  {
+    public RazorDirectiveAttribute([NotNull] string directive)
+    {
+      Directive = directive;
+    }
+
+    [NotNull] public string Directive { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+internal sealed class RazorPageBaseTypeAttribute : Attribute
+  {
+      public RazorPageBaseTypeAttribute([NotNull] string baseType)
+      {
+        BaseType = baseType;
+      }
+      public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
+      {
+          BaseType = baseType;
+          PageName = pageName;
+      }
+
+      [NotNull] public string BaseType { get; }
+      [CanBeNull] public string PageName { get; }
+  }
+
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class RazorHelperCommonAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Property)]
+internal sealed class RazorLayoutAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class RazorWriteLiteralMethodAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Method)]
+internal sealed class RazorWriteMethodAttribute : Attribute { }
+
+  [AttributeUsage(AttributeTargets.Parameter)]
+internal sealed class RazorWriteMethodParameterAttribute : Attribute { }
+
+  ///
+  /// Indicates that the marked parameter, field, or property is a route template.
+  ///
+  /// <remarks>
+  /// This attribute allows IDE to recognize the use of web frameworks' route templates
+  /// to enable syntax highlighting, code completion, navigation, rename and other features in string literals.
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class RouteTemplateAttribute : Attribute { }
+
+  ///
+  /// Indicates that the marked type is custom route parameter constraint,
+  /// which is registered in application's Startup with name <c>ConstraintName</c>
+  ///
+  /// <remarks>
+  /// You can specify <c>ProposedType</c> if target constraint matches only route parameters of specific type,
+  /// it will allow IDE to create method's parameter from usage in route template
+  /// with specified type instead of default <c>System.String</c>
+  /// and check if constraint's proposed type conflicts with matched parameter's type
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Class)]
+internal sealed class RouteParameterConstraintAttribute : Attribute
+  {
+    [NotNull] public string ConstraintName { get; }
+    [CanBeNull] public Type ProposedType { get; set; }
+
+    public RouteParameterConstraintAttribute([NotNull] string constraintName)
+    {
+      ConstraintName = constraintName;
+    }
+  }
+
+  ///
+  /// Indicates that the marked parameter, field, or property is an URI string.
+  ///
+  /// <remarks>
+  /// This attribute enables code completion, navigation, rename and other features
+  /// in URI string literals assigned to annotated parameter, field or property.
+  /// </remarks>
+  [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
+internal sealed class UriStringAttribute : Attribute
+  {
+    public UriStringAttribute() { }
+
+    public UriStringAttribute(string httpVerb)
+    {
+      HttpVerb = httpVerb;
+    }
+
+    [CanBeNull] public string HttpVerb { get; }
+  }
+}


nuget 1.0.0.5

nuget 1.0.0.5

--- CommonUtility/Properties/AssemblyInfo.cs
+++ CommonUtility/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
 // 可以指定所有值，也可以使用以下所示的 "*" 预置版本号和修订号
 //通过使用 "*"，如下所示:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.4")]
-[assembly: AssemblyFileVersion("1.0.0.4")]
+[assembly: AssemblyVersion("1.0.0.5")]
+[assembly: AssemblyFileVersion("1.0.0.5")]


Improved TryUnify and added overload

Improved TryUnify and added overload

TryUnify now checks if the referenced needles are Needle<T> and if they
are takes advantage of TryUnify on them.

--- Core/Theraot/Threading/Needles/Needle.cs
+++ Core/Theraot/Threading/Needles/Needle.cs
@@ -145,7 +145,11 @@
                 }
                 else
                 {
-                    value = _target;
+                    Needle<T> tmp = value as Needle<T>;
+                    if (ReferenceEquals(tmp, null) || !tmp.TryUnify(ref _target))
+                    {
+                        value = _target;
+                    }
                 }
                 return true;
             }
@@ -158,9 +162,8 @@
                 else
                 {
                     Needle<T> tmp = value as Needle<T>;
-                    if (!ReferenceEquals(tmp, null))
-                    {
-                        tmp.TryUnify(ref _target);
+                    if (!ReferenceEquals(tmp, null) && tmp.TryUnify(ref _target))
+                    {
                         Thread.MemoryBarrier();
                         return true;
                     }
@@ -169,8 +172,52 @@
                         tmp = _target as Needle<T>;
                         if (!ReferenceEquals(tmp, null))
                         {
-                            tmp.TryUnify(ref value);
-                            return true;
+                            return tmp.TryUnify(ref value);
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                }
+            }
+        }
+
+        public bool TryUnify(ref Needle<T> value)
+        {
+            if (ReferenceEquals(value, null))
+            {
+                if (ReferenceEquals(_target, null))
+                {
+                    value = new Needle<T>();
+                    _target = value;
+                    Thread.MemoryBarrier();
+                    return true;
+                }
+                else
+                {
+                    return value.TryUnify(ref _target);
+                }
+            }
+            else
+            {
+                if (ReferenceEquals(_target, value))
+                {
+                    return true;
+                }
+                else
+                {
+                    if (value.TryUnify(ref _target))
+                    {
+                        Thread.MemoryBarrier();
+                        return true;
+                    }
+                    else
+                    {
+                        Needle<T> tmp = _target as Needle<T>;
+                        if (!ReferenceEquals(tmp, null))
+                        {
+                            return tmp.TryUnify(ref value);
                         }
                         else
                         {


comment discard

comment discard

--- DependenciesGui/DependencyWindow.xaml.cs
+++ DependenciesGui/DependencyWindow.xaml.cs
@@ -557,7 +557,6 @@
                 if (ImportModule.PeFilePath == User32Filepath)
                 {
                     string AppInitRegistryKey =
-                       // When the X86 version DepenciesGui.exe program opens the WowAA32Node registry, it seems like a fault occurs.
                        (this.Pe.IsArm32Dll()) ?
                         "SOFTWARE\\WowAA32Node\\Microsoft\\Windows NT\\CurrentVersion\\Windows" :
                        (this.Pe.IsWow64Dll()) ?


Reuse serialized widget store when saving settings

--- DesktopWidgets/Helpers/SettingsHelper.cs
+++ DesktopWidgets/Helpers/SettingsHelper.cs
@@ -61,9 +61,9 @@
             App.WidgetsSettingsStore.EventActionPairs.CollectionChanged += (sender, args) => App.SaveTimer.DelaySave();
         }

-        private static void SaveWidgetsDataToSettings()
-        {
-            Settings.Default.Widgets = JsonConvert.SerializeObject(App.WidgetsSettingsStore, JsonSerializerSettings);
+        private static void SaveWidgetsDataToSettings(string serializedWidgetStore = null)
+        {
+            Settings.Default.Widgets = serializedWidgetStore ?? GetExportData();
         }

         public static void LoadSettings()
@@ -78,11 +78,13 @@
                 return;
             }

-            SaveWidgetsDataToSettings();
+            var serializedWidgetStore = GetExportData();
+
+            SaveWidgetsDataToSettings(serializedWidgetStore);

             if (Settings.Default.BackupInterval.TotalSeconds > 0 && DateTime.Now - Settings.Default.BackupInterval > Settings.Default.LastBackupDateTime)
             {
-                Backup();
+                Backup(serializedWidgetStore);
             }

             Settings.Default.Save();
@@ -200,7 +202,7 @@
             File.WriteAllText(dialog.FileName, GetExportData());
         }

-        private static void Backup()
+        private static void Backup(string serializedWidgetStore = null)
         {
             if (!App.SuccessfullyLoaded)
             {
@@ -209,7 +211,7 @@

             Settings.Default.LastBackupDateTime = DateTime.Now;
             var filename = $"backup-{DateTime.Now.ToString("yyMMddHHmmss")}{Resources.StoreExportExtension}";
-            FileSystemHelper.WriteTextToFile(Path.Combine(BackupDirectory, filename), GetExportData());
+            FileSystemHelper.WriteTextToFile(Path.Combine(BackupDirectory, filename), serializedWidgetStore ?? GetExportData());
         }

         public static void DeleteConfigFile(ConfigurationErrorsException configurationErrorsException)


Complete initial integration with jobs terrain data update

--- DistantTerrain/Scripts/DistantTerrain.cs
+++ DistantTerrain/Scripts/DistantTerrain.cs
@@ -162,6 +162,8 @@
         // texture for terrainInfoTileMap
         Texture2D textureTerrainInfoTileMap = null;

+        // Distance Terrain own instance of terrain texturing. (this should come from core at some point when mod mechanism is created)
+        TerrainTexturingJobs terrainTexturingJobs = new TerrainTexturingJobs();

         ClimateSeason currentSeason = ClimateSeason.Summer;

@@ -1456,8 +1458,12 @@
             // Update data for terrain
             //UpdateMapPixelData(ref dfTerrain, terrainDesc.mapPixelX, terrainDesc.mapPixelY, streamingWorld.TerrainTexturing);
             //dfTerrain.UpdateMapPixelData(streamingWorld.TerrainTexturing);
-            JobHandle updateTerrainDataHandle = dfTerrain.BeginMapPixelDataUpdate(streamingWorld.TerrainTexturingJobs);
+            JobHandle updateTerrainDataHandle = dfTerrain.BeginMapPixelDataUpdate(terrainTexturingJobs);
+
+            // AJRB: TODO: put jobified version of heights update in here... for now just request job completion.
             updateTerrainDataHandle.Complete();
+
+            dfTerrain.CompleteMapPixelDataUpdate(terrainTexturingJobs);

             // Update heights of transition terrain ring
             float weightFarTerrainLeft = 0.0f;
@@ -1496,10 +1502,9 @@
             }

             //dfTerrain.UpdateTileMapData();
-            dfTerrain.CompleteMapPixelDataUpdate(streamingWorld.TerrainTexturingJobs);

             // Promote data to live terrain
-/*            dfTerrain.UpdateClimateMaterial();
+            dfTerrain.UpdateClimateMaterial();

             // important to put call to dfTerrain.PromoteTerrainData into a try-catch block
             // (since it raises PromoteTerrainEvent and another mod that consumes the event
@@ -1513,7 +1518,7 @@
             {
                 Debug.LogError("exception after raising PromoteTerrainEvent in dfTerrain.PromoteTerrainData : " + e.Message);
             }
-*/
+
             // inject transition ring shader
             Terrain terrain = transitionTerrainDesc.terrainDesc.terrainObject.GetComponent<Terrain>();
             Material oldMaterial = terrain.materialTemplate;
@@ -1671,7 +1676,7 @@
             terrainTransitionRingArray[terrainIndex].terrainDesc.terrainObject.transform.localPosition = localPosition;

             // if block was not reused - it does not exist - so create unity terrain object - otherwise position update will be enough
-            if (true || !terrainTransitionRingArray[terrainIndex].keepThisBlock)    // AJRB: Always generate terrain data since it's disposed of.. Discuss with Nystul.
+            if (!terrainTransitionRingArray[terrainIndex].keepThisBlock)
             {
                 UpdateTerrainDataTransitionRing(terrainTransitionRingArray[terrainIndex]);
             }
@@ -1795,17 +1800,9 @@
                         yield return new WaitForEndOfFrame();
                     }

-                    // Log whenever the change that enforces always regenerating terrain data would have failed to layout nature
-                    if (terrainTransitionRingArray[i].keepThisBlock)
-                        Debug.LogFormat("Would not be updating terrain nature for ({0},{1})", terrainTransitionRingArray[i].terrainDesc.mapPixelX, terrainTransitionRingArray[i].terrainDesc.mapPixelY);
-
                     if (terrainTransitionRingArray[i].terrainDesc.updateNature)
                     {
-                        try {
-                            streamingWorld.UpdateTerrainNature(terrainTransitionRingArray[i].terrainDesc);
-                        } catch (Exception e) {
-                            Debug.LogFormat("Exception updating terrain nature! ({0},{1})", terrainTransitionRingArray[i].terrainDesc.mapPixelX, terrainTransitionRingArray[i].terrainDesc.mapPixelY, e);
-                        }
+                        streamingWorld.UpdateTerrainNature(terrainTransitionRingArray[i].terrainDesc);
                         terrainTransitionRingArray[i].terrainDesc.updateNature = false;

                         MeshRenderer meshRenderer = terrainTransitionRingArray[i].terrainDesc.billboardBatchObject.GetComponent<MeshRenderer>();