Commit 7840a4b9 authored by justcoding121's avatar justcoding121

cleanup test/example projects

parent 000f3715
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
......
...@@ -9,19 +9,19 @@ namespace Titanium.Web.Proxy.Examples.Basic.Helpers ...@@ -9,19 +9,19 @@ namespace Titanium.Web.Proxy.Examples.Basic.Helpers
/// </summary> /// </summary>
internal static class ConsoleHelper internal static class ConsoleHelper
{ {
const uint ENABLE_QUICK_EDIT = 0x0040; private const uint ENABLE_QUICK_EDIT = 0x0040;
// STD_INPUT_HANDLE (DWORD): -10 is the standard input device. // STD_INPUT_HANDLE (DWORD): -10 is the standard input device.
const int STD_INPUT_HANDLE = -10; private const int STD_INPUT_HANDLE = -10;
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetStdHandle(int nStdHandle); private static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode); private static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode); private static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
internal static bool DisableQuickEditMode() internal static bool DisableQuickEditMode()
{ {
......
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
......
...@@ -17,13 +17,16 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -17,13 +17,16 @@ namespace Titanium.Web.Proxy.Examples.Basic
private readonly object lockObj = new object(); private readonly object lockObj = new object();
private readonly ProxyServer proxyServer; private readonly ProxyServer proxyServer;
private ExplicitProxyEndPoint explicitEndPoint;
//keep track of request headers //keep track of request headers
private readonly IDictionary<Guid, HeaderCollection> requestHeaderHistory = new ConcurrentDictionary<Guid, HeaderCollection>(); private readonly IDictionary<Guid, HeaderCollection> requestHeaderHistory =
new ConcurrentDictionary<Guid, HeaderCollection>();
//keep track of response headers //keep track of response headers
private readonly IDictionary<Guid, HeaderCollection> responseHeaderHistory = new ConcurrentDictionary<Guid, HeaderCollection>(); private readonly IDictionary<Guid, HeaderCollection> responseHeaderHistory =
new ConcurrentDictionary<Guid, HeaderCollection>();
private ExplicitProxyEndPoint explicitEndPoint;
//share requestBody outside handlers //share requestBody outside handlers
//Using a dictionary is not a good idea since it can cause memory overflow //Using a dictionary is not a good idea since it can cause memory overflow
...@@ -78,13 +81,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -78,13 +81,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.EnableWinAuth = true; //proxyServer.EnableWinAuth = true;
explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000) explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000);
{
//Use self-issued generic certificate on all https requests
//Optimizes performance by not creating a certificate for each https-enabled domain
//Useful when certificate trust is not required by proxy clients
//GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "genericcert.pfx"), "password")
};
//Fired when a CONNECT request is received //Fired when a CONNECT request is received
explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest; explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest;
...@@ -111,7 +108,10 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -111,7 +108,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 }; //proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
foreach (var endPoint in proxyServer.ProxyEndPoints) foreach (var endPoint in proxyServer.ProxyEndPoints)
Console.WriteLine("Listening on '{0}' endpoint at Ip {1} and port: {2} ", endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port); {
Console.WriteLine("Listening on '{0}' endpoint at Ip {1} and port: {2} ", endPoint.GetType().Name,
endPoint.IpAddress, endPoint.Port);
}
#if NETSTANDARD2_0 #if NETSTANDARD2_0
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup> </startup>
</configuration> </configuration>
\ No newline at end of file
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<GridSplitter Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" /> <GridSplitter Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" />
<ListView Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" ItemsSource="{Binding Sessions}" SelectedItem="{Binding SelectedSession}" <ListView Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" ItemsSource="{Binding Sessions}"
SelectedItem="{Binding SelectedSession}"
KeyDown="ListViewSessions_OnKeyDown"> KeyDown="ListViewSessions_OnKeyDown">
<ListView.View> <ListView.View>
<GridView> <GridView>
......
...@@ -20,44 +20,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -20,44 +20,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private readonly ProxyServer proxyServer;
private int lastSessionNumber;
public ObservableCollection<SessionListItem> Sessions { get; } = new ObservableCollection<SessionListItem>();
public SessionListItem SelectedSession
{
get => selectedSession;
set
{
if (value != selectedSession)
{
selectedSession = value;
SelectedSessionChanged();
}
}
}
public static readonly DependencyProperty ClientConnectionCountProperty = DependencyProperty.Register( public static readonly DependencyProperty ClientConnectionCountProperty = DependencyProperty.Register(
nameof(ClientConnectionCount), typeof(int), typeof(MainWindow), new PropertyMetadata(default(int))); nameof(ClientConnectionCount), typeof(int), typeof(MainWindow), new PropertyMetadata(default(int)));
public int ClientConnectionCount
{
get => (int)GetValue(ClientConnectionCountProperty);
set => SetValue(ClientConnectionCountProperty, value);
}
public static readonly DependencyProperty ServerConnectionCountProperty = DependencyProperty.Register( public static readonly DependencyProperty ServerConnectionCountProperty = DependencyProperty.Register(
nameof(ServerConnectionCount), typeof(int), typeof(MainWindow), new PropertyMetadata(default(int))); nameof(ServerConnectionCount), typeof(int), typeof(MainWindow), new PropertyMetadata(default(int)));
public int ServerConnectionCount private readonly ProxyServer proxyServer;
{
get => (int)GetValue(ServerConnectionCountProperty);
set => SetValue(ServerConnectionCountProperty, value);
}
private readonly Dictionary<HttpWebClient, SessionListItem> sessionDictionary = new Dictionary<HttpWebClient, SessionListItem>(); private readonly Dictionary<HttpWebClient, SessionListItem> sessionDictionary =
new Dictionary<HttpWebClient, SessionListItem>();
private int lastSessionNumber;
private SessionListItem selectedSession; private SessionListItem selectedSession;
public MainWindow() public MainWindow()
...@@ -105,8 +79,14 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -105,8 +79,14 @@ namespace Titanium.Web.Proxy.Examples.Wpf
proxyServer.AfterResponse += ProxyServer_AfterResponse; proxyServer.AfterResponse += ProxyServer_AfterResponse;
explicitEndPoint.BeforeTunnelConnectRequest += ProxyServer_BeforeTunnelConnectRequest; explicitEndPoint.BeforeTunnelConnectRequest += ProxyServer_BeforeTunnelConnectRequest;
explicitEndPoint.BeforeTunnelConnectResponse += ProxyServer_BeforeTunnelConnectResponse; explicitEndPoint.BeforeTunnelConnectResponse += ProxyServer_BeforeTunnelConnectResponse;
proxyServer.ClientConnectionCountChanged += delegate { Dispatcher.Invoke(() => { ClientConnectionCount = proxyServer.ClientConnectionCount; }); }; proxyServer.ClientConnectionCountChanged += delegate
proxyServer.ServerConnectionCountChanged += delegate { Dispatcher.Invoke(() => { ServerConnectionCount = proxyServer.ServerConnectionCount; }); }; {
Dispatcher.Invoke(() => { ClientConnectionCount = proxyServer.ClientConnectionCount; });
};
proxyServer.ServerConnectionCountChanged += delegate
{
Dispatcher.Invoke(() => { ServerConnectionCount = proxyServer.ServerConnectionCount; });
};
proxyServer.Start(); proxyServer.Start();
proxyServer.SetAsSystemProxy(explicitEndPoint, ProxyProtocolType.AllHttp); proxyServer.SetAsSystemProxy(explicitEndPoint, ProxyProtocolType.AllHttp);
...@@ -114,6 +94,33 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -114,6 +94,33 @@ namespace Titanium.Web.Proxy.Examples.Wpf
InitializeComponent(); InitializeComponent();
} }
public ObservableCollection<SessionListItem> Sessions { get; } = new ObservableCollection<SessionListItem>();
public SessionListItem SelectedSession
{
get => selectedSession;
set
{
if (value != selectedSession)
{
selectedSession = value;
SelectedSessionChanged();
}
}
}
public int ClientConnectionCount
{
get => (int)GetValue(ClientConnectionCountProperty);
set => SetValue(ClientConnectionCountProperty, value);
}
public int ServerConnectionCount
{
get => (int)GetValue(ServerConnectionCountProperty);
set => SetValue(ServerConnectionCountProperty, value);
}
private async Task ProxyServer_BeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e) private async Task ProxyServer_BeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{ {
string hostname = e.WebSession.Request.RequestUri.Host; string hostname = e.WebSession.Request.RequestUri.Host;
...@@ -122,10 +129,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -122,10 +129,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e.DecryptSsl = false; e.DecryptSsl = false;
} }
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() => { AddSession(e); });
{
AddSession(e);
});
} }
private async Task ProxyServer_BeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e) private async Task ProxyServer_BeforeTunnelConnectResponse(object sender, TunnelConnectSessionEventArgs e)
...@@ -142,10 +146,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -142,10 +146,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private async Task ProxyServer_BeforeRequest(object sender, SessionEventArgs e) private async Task ProxyServer_BeforeRequest(object sender, SessionEventArgs e)
{ {
SessionListItem item = null; SessionListItem item = null;
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() => { item = AddSession(e); });
{
item = AddSession(e);
});
if (e.WebSession.Request.HasBody) if (e.WebSession.Request.HasBody)
{ {
...@@ -172,10 +173,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -172,10 +173,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
e.WebSession.Response.KeepBody = true; e.WebSession.Response.KeepBody = true;
await e.GetResponseBody(); await e.GetResponseBody();
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() => { item.Update(); });
{
item.Update();
});
} }
} }
} }
...@@ -207,7 +205,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -207,7 +205,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{ {
Number = lastSessionNumber, Number = lastSessionNumber,
WebSession = e.WebSession, WebSession = e.WebSession,
IsTunnelConnect = isTunnelConnect, IsTunnelConnect = isTunnelConnect
}; };
if (isTunnelConnect || e.WebSession.Request.UpgradeToWebSocket) if (isTunnelConnect || e.WebSession.Request.UpgradeToWebSocket)
......
...@@ -36,33 +36,41 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -36,33 +36,41 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// Indicates that the value of the marked element could be <c>null</c> sometimes, /// 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. /// so the check for <c>null</c> is necessary before its usage.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [CanBeNull] object Test() => null; /// [CanBeNull] object Test() => null;
/// ///
/// void UseTest() { /// void UseTest() {
/// var p = Test(); /// var p = Test();
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage( [AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
public sealed class CanBeNullAttribute : Attribute { } public sealed class CanBeNullAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that the value of the marked element could never be <c>null</c>. /// Indicates that the value of the marked element could never be <c>null</c>.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [NotNull] object Foo() { /// [NotNull] object Foo() {
/// return null; // Warning: Possible 'null' assignment /// return null; // Warning: Possible 'null' assignment
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage( [AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event |
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)]
public sealed class NotNullAttribute : Attribute { } public sealed class NotNullAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
...@@ -72,7 +80,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -72,7 +80,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage( [AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field)] AttributeTargets.Delegate | AttributeTargets.Field)]
public sealed class ItemNotNullAttribute : Attribute { } public sealed class ItemNotNullAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
...@@ -82,21 +92,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -82,21 +92,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage( [AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field)] AttributeTargets.Delegate | AttributeTargets.Field)]
public sealed class ItemCanBeNullAttribute : Attribute { } public sealed class ItemCanBeNullAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that the marked method builds string by format pattern and (optional) arguments. /// 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 /// 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. /// should be in <see cref="string.Format(IFormatProvider,string,object[])" />-like form.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [StringFormatMethod("message")] /// [StringFormatMethod("message")]
/// void ShowError(string message, params object[] args) { /* do something */ } /// void ShowError(string message, params object[] args) { /* do something */ }
/// ///
/// void Foo() { /// void Foo() {
/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage( [AttributeUsage(
AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Method |
AttributeTargets.Property | AttributeTargets.Delegate)] AttributeTargets.Property | AttributeTargets.Delegate)]
...@@ -110,7 +124,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -110,7 +124,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
FormatParameterName = formatParameterName; FormatParameterName = formatParameterName;
} }
[NotNull] public string FormatParameterName { get; private set; } [NotNull]
public string FormatParameterName { get; }
} }
/// <summary> /// <summary>
...@@ -127,22 +142,27 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -127,22 +142,27 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Name = name; Name = name;
} }
[NotNull] public string Name { get; private set; } [NotNull]
public string Name { get; }
} }
/// <summary> /// <summary>
/// Indicates that the function argument should be string literal and match one /// Indicates that the function argument should be string literal and match one
/// of the parameters of the caller function. For example, ReSharper annotates /// of the parameters of the caller function. For example, ReSharper annotates
/// the parameter of <see cref="System.ArgumentNullException"/>. /// the parameter of <see cref="System.ArgumentNullException" />.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// void Foo(string param) { /// void Foo(string param) {
/// if (param == null) /// if (param == null)
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class InvokerParameterNameAttribute : Attribute { } public sealed class InvokerParameterNameAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that the method is contained in a type that implements /// Indicates that the method is contained in a type that implements
...@@ -152,14 +172,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -152,14 +172,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <remarks> /// <remarks>
/// The method should be non-static and conform to one of the supported signatures: /// The method should be non-static and conform to one of the supported signatures:
/// <list> /// <list>
/// <item><c>NotifyChanged(string)</c></item> /// <item>
/// <item><c>NotifyChanged(params string[])</c></item> /// <c>NotifyChanged(string)</c>
/// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item> /// </item>
/// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item> /// <item>
/// <item><c>SetProperty{T}(ref T, T, string)</c></item> /// <c>NotifyChanged(params string[])</c>
/// </item>
/// <item>
/// <c>NotifyChanged{T}(Expression{Func{T}})</c>
/// </item>
/// <item>
/// <c>NotifyChanged{T,U}(Expression{Func{T,U}})</c>
/// </item>
/// <item>
/// <c>SetProperty{T}(ref T, T, string)</c>
/// </item>
/// </list> /// </list>
/// </remarks> /// </remarks>
/// <example><code> /// <example>
/// <code>
/// public class Foo : INotifyPropertyChanged { /// public class Foo : INotifyPropertyChanged {
/// public event PropertyChangedEventHandler PropertyChanged; /// public event PropertyChangedEventHandler PropertyChanged;
/// ///
...@@ -176,22 +207,34 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -176,22 +207,34 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// </code> /// </code>
/// Examples of generated notifications: /// Examples of generated notifications:
/// <list> /// <list>
/// <item><c>NotifyChanged("Property")</c></item> /// <item>
/// <item><c>NotifyChanged(() =&gt; Property)</c></item> /// <c>NotifyChanged("Property")</c>
/// <item><c>NotifyChanged((VM x) =&gt; x.Property)</c></item> /// </item>
/// <item><c>SetProperty(ref myField, value, "Property")</c></item> /// <item>
/// <c>NotifyChanged(() =&gt; Property)</c>
/// </item>
/// <item>
/// <c>NotifyChanged((VM x) =&gt; x.Property)</c>
/// </item>
/// <item>
/// <c>SetProperty(ref myField, value, "Property")</c>
/// </item>
/// </list> /// </list>
/// </example> /// </example>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
{ {
public NotifyPropertyChangedInvocatorAttribute() { } public NotifyPropertyChangedInvocatorAttribute()
{
}
public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
{ {
ParameterName = parameterName; ParameterName = parameterName;
} }
[CanBeNull] public string ParameterName { get; private set; } [CanBeNull]
public string ParameterName { get; }
} }
/// <summary> /// <summary>
...@@ -206,43 +249,57 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -206,43 +249,57 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item> /// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
/// <item>Value ::= true | false | null | notnull | canbenull</item> /// <item>Value ::= true | false | null | notnull | canbenull</item>
/// </list> /// </list>
/// If method has single input parameter, it's name could be omitted.<br/> /// If method has single input parameter, it's name could be omitted.<br />
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same) for method output /// 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 (throws or terminates the process).<br/> /// means that the methos doesn't return normally (throws or terminates the process).<br />
/// Value <c>canbenull</c> is only applicable for output parameters.<br/> /// Value <c>canbenull</c> is only applicable for output parameters.<br />
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute /// You can use multiple <c>[ContractAnnotation]</c> for each FDT row, or use single attribute
/// with rows separated by semicolon. There is no notion of order rows, all rows are checked /// with rows separated by semicolon. There is no notion of order rows, all rows are checked
/// for applicability and applied per each program state tracked by R# analysis.<br/> /// for applicability and applied per each program state tracked by R# analysis.<br />
/// </syntax> /// </syntax>
/// <examples><list> /// <examples>
/// <item><code> /// <list>
/// <item>
/// <code>
/// [ContractAnnotation("=&gt; halt")] /// [ContractAnnotation("=&gt; halt")]
/// public void TerminationMethod() /// public void TerminationMethod()
/// </code></item> /// </code>
/// <item><code> /// </item>
/// <item>
/// <code>
/// [ContractAnnotation("halt &lt;= condition: false")] /// [ContractAnnotation("halt &lt;= condition: false")]
/// public void Assert(bool condition, string text) // regular assertion method /// public void Assert(bool condition, string text) // regular assertion method
/// </code></item> /// </code>
/// <item><code> /// </item>
/// <item>
/// <code>
/// [ContractAnnotation("s:null =&gt; true")] /// [ContractAnnotation("s:null =&gt; true")]
/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
/// </code></item> /// </code>
/// <item><code> /// </item>
/// <item>
/// <code>
/// // A method that returns null if the parameter is null, /// // A method that returns null if the parameter is null,
/// // and not null if the parameter is not null /// // and not null if the parameter is not null
/// [ContractAnnotation("null =&gt; null; notnull =&gt; notnull")] /// [ContractAnnotation("null =&gt; null; notnull =&gt; notnull")]
/// public object Transform(object data) /// public object Transform(object data)
/// </code></item> /// </code>
/// <item><code> /// </item>
/// <item>
/// <code>
/// [ContractAnnotation("=&gt; true, result: notnull; =&gt; false, result: null")] /// [ContractAnnotation("=&gt; true, result: notnull; =&gt; false, result: null")]
/// public bool TryParse(string s, out Person result) /// public bool TryParse(string s, out Person result)
/// </code></item> /// </code>
/// </list></examples> /// </item>
/// </list>
/// </examples>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class ContractAnnotationAttribute : Attribute public sealed class ContractAnnotationAttribute : Attribute
{ {
public ContractAnnotationAttribute([NotNull] string contract) public ContractAnnotationAttribute([NotNull] string contract)
: this(contract, false) { } : this(contract, false)
{
}
public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
{ {
...@@ -250,31 +307,36 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -250,31 +307,36 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
ForceFullStates = forceFullStates; ForceFullStates = forceFullStates;
} }
[NotNull] public string Contract { get; private set; } [NotNull]
public string Contract { get; }
public bool ForceFullStates { get; private set; } public bool ForceFullStates { get; }
} }
/// <summary> /// <summary>
/// Indicates that marked element should be localized or not. /// Indicates that marked element should be localized or not.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [LocalizationRequiredAttribute(true)] /// [LocalizationRequiredAttribute(true)]
/// class Foo { /// class Foo {
/// string str = "my string"; // Warning: Localizable string /// string str = "my string"; // Warning: Localizable string
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage(AttributeTargets.All)] [AttributeUsage(AttributeTargets.All)]
public sealed class LocalizationRequiredAttribute : Attribute public sealed class LocalizationRequiredAttribute : Attribute
{ {
public LocalizationRequiredAttribute() : this(true) { } public LocalizationRequiredAttribute() : this(true)
{
}
public LocalizationRequiredAttribute(bool required) public LocalizationRequiredAttribute(bool required)
{ {
Required = required; Required = required;
} }
public bool Required { get; private set; } public bool Required { get; }
} }
/// <summary> /// <summary>
...@@ -283,7 +345,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -283,7 +345,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// should be used instead. However, using '==' or '!=' for comparison /// should be used instead. However, using '==' or '!=' for comparison
/// with <c>null</c> is always permitted. /// with <c>null</c> is always permitted.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [CannotApplyEqualityOperator] /// [CannotApplyEqualityOperator]
/// class NoEquality { } /// class NoEquality { }
/// ///
...@@ -296,21 +359,26 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -296,21 +359,26 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// } /// }
/// } /// }
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } public sealed class CannotApplyEqualityOperatorAttribute : Attribute
{
}
/// <summary> /// <summary>
/// When applied to a target attribute, specifies a requirement for any type marked /// When applied to a target attribute, specifies a requirement for any type marked
/// with the target attribute to implement or inherit specific type or types. /// with the target attribute to implement or inherit specific type or types.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
/// class ComponentAttribute : Attribute { } /// class ComponentAttribute : Attribute { }
/// ///
/// [Component] // ComponentAttribute requires implementing IComponent interface /// [Component] // ComponentAttribute requires implementing IComponent interface
/// class MyComponent : IComponent { } /// class MyComponent : IComponent { }
/// </code></example> /// </code>
/// </example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof(Attribute))] [BaseTypeRequired(typeof(Attribute))]
public sealed class BaseTypeRequiredAttribute : Attribute public sealed class BaseTypeRequiredAttribute : Attribute
...@@ -320,7 +388,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -320,7 +388,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
BaseType = baseType; BaseType = baseType;
} }
[NotNull] public Type BaseType { get; private set; } [NotNull]
public Type BaseType { get; }
} }
/// <summary> /// <summary>
...@@ -331,13 +400,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -331,13 +400,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
public sealed class UsedImplicitlyAttribute : Attribute public sealed class UsedImplicitlyAttribute : Attribute
{ {
public UsedImplicitlyAttribute() public UsedImplicitlyAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
{
}
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
: this(useKindFlags, ImplicitUseTargetFlags.Default) { } : this(useKindFlags, ImplicitUseTargetFlags.Default)
{
}
public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
: this(ImplicitUseKindFlags.Default, targetFlags) { } : this(ImplicitUseKindFlags.Default, targetFlags)
{
}
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
{ {
...@@ -345,9 +420,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -345,9 +420,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
TargetFlags = targetFlags; TargetFlags = targetFlags;
} }
public ImplicitUseKindFlags UseKindFlags { get; private set; } public ImplicitUseKindFlags UseKindFlags { get; }
public ImplicitUseTargetFlags TargetFlags { get; private set; } public ImplicitUseTargetFlags TargetFlags { get; }
} }
/// <summary> /// <summary>
...@@ -358,13 +433,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -358,13 +433,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
public sealed class MeansImplicitUseAttribute : Attribute public sealed class MeansImplicitUseAttribute : Attribute
{ {
public MeansImplicitUseAttribute() public MeansImplicitUseAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
{
}
public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
: this(useKindFlags, ImplicitUseTargetFlags.Default) { } : this(useKindFlags, ImplicitUseTargetFlags.Default)
{
}
public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
: this(ImplicitUseKindFlags.Default, targetFlags) { } : this(ImplicitUseKindFlags.Default, targetFlags)
{
}
public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
{ {
...@@ -372,39 +453,47 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -372,39 +453,47 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
TargetFlags = targetFlags; TargetFlags = targetFlags;
} }
[UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } [UsedImplicitly]
public ImplicitUseKindFlags UseKindFlags { get; private set; }
[UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } [UsedImplicitly]
public ImplicitUseTargetFlags TargetFlags { get; private set; }
} }
[Flags] [Flags]
public enum ImplicitUseKindFlags public enum ImplicitUseKindFlags
{ {
Default = Access | Assign | InstantiatedWithFixedConstructorSignature, Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
/// <summary>Only entity marked with attribute considered used.</summary> /// <summary>Only entity marked with attribute considered used.</summary>
Access = 1, Access = 1,
/// <summary>Indicates implicit assignment to a member.</summary> /// <summary>Indicates implicit assignment to a member.</summary>
Assign = 2, Assign = 2,
/// <summary> /// <summary>
/// Indicates implicit instantiation of a type with fixed constructor signature. /// Indicates implicit instantiation of a type with fixed constructor signature.
/// That means any unused constructor parameters won't be reported as such. /// That means any unused constructor parameters won't be reported as such.
/// </summary> /// </summary>
InstantiatedWithFixedConstructorSignature = 4, InstantiatedWithFixedConstructorSignature = 4,
/// <summary>Indicates implicit instantiation of a type.</summary> /// <summary>Indicates implicit instantiation of a type.</summary>
InstantiatedNoFixedConstructorSignature = 8, InstantiatedNoFixedConstructorSignature = 8
} }
/// <summary> /// <summary>
/// Specify what is considered used implicitly when marked /// Specify what is considered used implicitly when marked
/// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>. /// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
/// </summary> /// </summary>
[Flags] [Flags]
public enum ImplicitUseTargetFlags public enum ImplicitUseTargetFlags
{ {
Default = Itself, Default = Itself,
Itself = 1, Itself = 1,
/// <summary>Members of entity marked with attribute are considered used.</summary> /// <summary>Members of entity marked with attribute are considered used.</summary>
Members = 2, Members = 2,
/// <summary>Entity marked with attribute and all its members considered used.</summary> /// <summary>Entity marked with attribute and all its members considered used.</summary>
WithMembers = Itself | Members WithMembers = Itself | Members
} }
...@@ -416,14 +505,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -416,14 +505,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
public sealed class PublicAPIAttribute : Attribute public sealed class PublicAPIAttribute : Attribute
{ {
public PublicAPIAttribute() { } public PublicAPIAttribute()
{
}
public PublicAPIAttribute([NotNull] string comment) public PublicAPIAttribute([NotNull] string comment)
{ {
Comment = comment; Comment = comment;
} }
[CanBeNull] public string Comment { get; private set; } [CanBeNull]
public string Comment { get; }
} }
/// <summary> /// <summary>
...@@ -432,21 +524,27 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -432,21 +524,27 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class InstantHandleAttribute : Attribute { } public sealed class InstantHandleAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that a method does not make any observable state changes. /// Indicates that a method does not make any observable state changes.
/// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>. /// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [Pure] int Multiply(int x, int y) => x * y; /// [Pure] int Multiply(int x, int y) => x * y;
/// ///
/// void M() { /// void M() {
/// Multiply(123, 42); // Waring: Return value of pure method is not used /// Multiply(123, 42); // Waring: Return value of pure method is not used
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class PureAttribute : Attribute { } public sealed class PureAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that the return value of method invocation must be used. /// Indicates that the return value of method invocation must be used.
...@@ -454,14 +552,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -454,14 +552,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class MustUseReturnValueAttribute : Attribute public sealed class MustUseReturnValueAttribute : Attribute
{ {
public MustUseReturnValueAttribute() { } public MustUseReturnValueAttribute()
{
}
public MustUseReturnValueAttribute([NotNull] string justification) public MustUseReturnValueAttribute([NotNull] string justification)
{ {
Justification = justification; Justification = justification;
} }
[CanBeNull] public string Justification { get; private set; } [CanBeNull]
public string Justification { get; }
} }
/// <summary> /// <summary>
...@@ -469,7 +570,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -469,7 +570,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// to get the value that type. This annotation is useful when you have some "context" value evaluated /// to get the value 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. /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// class Foo { /// class Foo {
/// [ProvidesContext] IBarService _barService = ...; /// [ProvidesContext] IBarService _barService = ...;
/// ///
...@@ -478,11 +580,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -478,11 +580,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// // ^ Warning: use value of '_barService' field /// // ^ Warning: use value of '_barService' field
/// } /// }
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage( [AttributeUsage(
AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method |
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct |
public sealed class ProvidesContextAttribute : Attribute { } AttributeTargets.GenericParameter)]
public sealed class ProvidesContextAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that a parameter is a path to a file or a folder within a web project. /// Indicates that a parameter is a path to a file or a folder within a web project.
...@@ -491,14 +597,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -491,14 +597,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class PathReferenceAttribute : Attribute public sealed class PathReferenceAttribute : Attribute
{ {
public PathReferenceAttribute() { } public PathReferenceAttribute()
{
}
public PathReferenceAttribute([NotNull, PathReference] string basePath) public PathReferenceAttribute([NotNull] [PathReference] string basePath)
{ {
BasePath = basePath; BasePath = basePath;
} }
[CanBeNull] public string BasePath { get; private set; } [CanBeNull]
public string BasePath { get; }
} }
/// <summary> /// <summary>
...@@ -510,7 +619,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -510,7 +619,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// Template method body can contain valid source code and/or special comments starting with '$'. /// 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 /// 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. /// 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. /// Use the <see cref="MacroAttribute" /> attribute to specify macros for parameters.
/// </remarks> /// </remarks>
/// <example> /// <example>
/// In this example, the 'forEach' method is a source template available over all values /// In this example, the 'forEach' method is a source template available over all values
...@@ -525,16 +634,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -525,16 +634,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// </code> /// </code>
/// </example> /// </example>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class SourceTemplateAttribute : Attribute { } public sealed class SourceTemplateAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>. /// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression /// 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 /// 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 /// 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. /// for the parameter, set the <see cref="MacroAttribute.Editable" /> property value = -1.
/// </remarks> /// </remarks>
/// <example> /// <example>
/// Applying the attribute on a source template method: /// Applying the attribute on a source template method:
...@@ -562,7 +673,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -562,7 +673,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see> /// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
/// parameter when the template is expanded. /// parameter when the template is expanded.
/// </summary> /// </summary>
[CanBeNull] public string Expression { get; set; } [CanBeNull]
public string Expression { get; set; }
/// <summary> /// <summary>
/// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
...@@ -571,17 +683,20 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -571,17 +683,20 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// If the target parameter is used several times in the template, only one occurrence becomes editable; /// 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, /// 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. /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
/// </remarks>> /// </remarks>
/// >
public int Editable { get; set; } public int Editable { get; set; }
/// <summary> /// <summary>
/// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the /// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
/// <see cref="MacroAttribute"/> is applied on a template method. /// <see cref="MacroAttribute" /> is applied on a template method.
/// </summary> /// </summary>
[CanBeNull] public string Target { get; set; } [CanBeNull]
public string Target { get; set; }
} }
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =
true)]
public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
{ {
public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
...@@ -589,10 +704,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -589,10 +704,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Format = format; Format = format;
} }
[NotNull] public string Format { get; private set; } [NotNull]
public string Format { get; }
} }
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =
true)]
public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
{ {
public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
...@@ -600,10 +717,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -600,10 +717,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Format = format; Format = format;
} }
[NotNull] public string Format { get; private set; } [NotNull]
public string Format { get; }
} }
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =
true)]
public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
{ {
public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
...@@ -611,10 +730,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -611,10 +730,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Format = format; Format = format;
} }
[NotNull] public string Format { get; private set; } [NotNull]
public string Format { get; }
} }
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =
true)]
public sealed class AspMvcMasterLocationFormatAttribute : Attribute public sealed class AspMvcMasterLocationFormatAttribute : Attribute
{ {
public AspMvcMasterLocationFormatAttribute([NotNull] string format) public AspMvcMasterLocationFormatAttribute([NotNull] string format)
...@@ -622,10 +743,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -622,10 +743,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Format = format; Format = format;
} }
[NotNull] public string Format { get; private set; } [NotNull]
public string Format { get; }
} }
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =
true)]
public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
{ {
public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
...@@ -633,10 +756,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -633,10 +756,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Format = format; Format = format;
} }
[NotNull] public string Format { get; private set; } [NotNull]
public string Format { get; }
} }
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple =
true)]
public sealed class AspMvcViewLocationFormatAttribute : Attribute public sealed class AspMvcViewLocationFormatAttribute : Attribute
{ {
public AspMvcViewLocationFormatAttribute([NotNull] string format) public AspMvcViewLocationFormatAttribute([NotNull] string format)
...@@ -644,7 +769,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -644,7 +769,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Format = format; Format = format;
} }
[NotNull] public string Format { get; private set; } [NotNull]
public string Format { get; }
} }
/// <summary> /// <summary>
...@@ -656,14 +782,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -656,14 +782,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcActionAttribute : Attribute public sealed class AspMvcActionAttribute : Attribute
{ {
public AspMvcActionAttribute() { } public AspMvcActionAttribute()
{
}
public AspMvcActionAttribute([NotNull] string anonymousProperty) public AspMvcActionAttribute([NotNull] string anonymousProperty)
{ {
AnonymousProperty = anonymousProperty; AnonymousProperty = anonymousProperty;
} }
[CanBeNull] public string AnonymousProperty { get; private set; } [CanBeNull]
public string AnonymousProperty { get; }
} }
/// <summary> /// <summary>
...@@ -674,14 +803,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -674,14 +803,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcAreaAttribute : Attribute public sealed class AspMvcAreaAttribute : Attribute
{ {
public AspMvcAreaAttribute() { } public AspMvcAreaAttribute()
{
}
public AspMvcAreaAttribute([NotNull] string anonymousProperty) public AspMvcAreaAttribute([NotNull] string anonymousProperty)
{ {
AnonymousProperty = anonymousProperty; AnonymousProperty = anonymousProperty;
} }
[CanBeNull] public string AnonymousProperty { get; private set; } [CanBeNull]
public string AnonymousProperty { get; }
} }
/// <summary> /// <summary>
...@@ -693,14 +825,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -693,14 +825,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcControllerAttribute : Attribute public sealed class AspMvcControllerAttribute : Attribute
{ {
public AspMvcControllerAttribute() { } public AspMvcControllerAttribute()
{
}
public AspMvcControllerAttribute([NotNull] string anonymousProperty) public AspMvcControllerAttribute([NotNull] string anonymousProperty)
{ {
AnonymousProperty = anonymousProperty; AnonymousProperty = anonymousProperty;
} }
[CanBeNull] public string AnonymousProperty { get; private set; } [CanBeNull]
public string AnonymousProperty { get; }
} }
/// <summary> /// <summary>
...@@ -708,14 +843,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -708,14 +843,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>. /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcMasterAttribute : Attribute { } public sealed class AspMvcMasterAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute
/// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>. /// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcModelTypeAttribute : Attribute { } public sealed class AspMvcModelTypeAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
...@@ -724,13 +863,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -724,13 +863,17 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>. /// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcPartialViewAttribute : Attribute { } public sealed class AspMvcPartialViewAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class AspMvcSuppressViewErrorAttribute : Attribute { } public sealed class AspMvcSuppressViewErrorAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
...@@ -738,7 +881,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -738,7 +881,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>. /// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcDisplayTemplateAttribute : Attribute { } public sealed class AspMvcDisplayTemplateAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template.
...@@ -746,7 +891,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -746,7 +891,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>. /// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcEditorTemplateAttribute : Attribute { } public sealed class AspMvcEditorTemplateAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
...@@ -754,7 +901,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -754,7 +901,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>. /// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcTemplateAttribute : Attribute { } public sealed class AspMvcTemplateAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
...@@ -763,47 +912,60 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -763,47 +912,60 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <c>System.Web.Mvc.Controller.View(Object)</c>. /// <c>System.Web.Mvc.Controller.View(Object)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcViewAttribute : Attribute { } public sealed class AspMvcViewAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// is an MVC view component name. /// is an MVC view component name.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcViewComponentAttribute : Attribute { } public sealed class AspMvcViewComponentAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter /// 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. /// is an MVC view component view. If applied to a method, the MVC view component view name is default.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcViewComponentViewAttribute : Attribute { } public sealed class AspMvcViewComponentViewAttribute : Attribute
{
}
/// <summary> /// <summary>
/// ASP.NET MVC attribute. When applied to a parameter of an 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.
/// </summary> /// </summary>
/// <example><code> /// <example>
/// <code>
/// [ActionName("Foo")] /// [ActionName("Foo")]
/// public ActionResult Login(string returnUrl) { /// public ActionResult Login(string returnUrl) {
/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
/// return RedirectToAction("Bar"); // Error: Cannot resolve action /// return RedirectToAction("Bar"); // Error: Cannot resolve action
/// } /// }
/// </code></example> /// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public sealed class AspMvcActionSelectorAttribute : Attribute { } public sealed class AspMvcActionSelectorAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
public sealed class HtmlElementAttributesAttribute : Attribute public sealed class HtmlElementAttributesAttribute : Attribute
{ {
public HtmlElementAttributesAttribute() { } public HtmlElementAttributesAttribute()
{
}
public HtmlElementAttributesAttribute([NotNull] string name) public HtmlElementAttributesAttribute([NotNull] string name)
{ {
Name = name; Name = name;
} }
[CanBeNull] public string Name { get; private set; } [CanBeNull]
public string Name { get; }
} }
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
...@@ -814,7 +976,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -814,7 +976,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Name = name; Name = name;
} }
[NotNull] public string Name { get; private set; } [NotNull]
public string Name { get; }
} }
/// <summary> /// <summary>
...@@ -823,7 +986,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -823,7 +986,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>. /// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class RazorSectionAttribute : Attribute { } public sealed class RazorSectionAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates how method, constructor invocation or property access /// Indicates how method, constructor invocation or property access
...@@ -837,7 +1002,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -837,7 +1002,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
CollectionAccessType = collectionAccessType; CollectionAccessType = collectionAccessType;
} }
public CollectionAccessType CollectionAccessType { get; private set; } public CollectionAccessType CollectionAccessType { get; }
} }
[Flags] [Flags]
...@@ -845,10 +1010,13 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -845,10 +1010,13 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
{ {
/// <summary>Method does not use or modify content of the collection.</summary> /// <summary>Method does not use or modify content of the collection.</summary>
None = 0, None = 0,
/// <summary>Method only reads content of the collection but does not modify it.</summary> /// <summary>Method only reads content of the collection but does not modify it.</summary>
Read = 1, Read = 1,
/// <summary>Method can change content of the collection but does not add new elements.</summary> /// <summary>Method can change content of the collection but does not add new elements.</summary>
ModifyExistingContent = 2, ModifyExistingContent = 2,
/// <summary>Method can add new elements to the collection.</summary> /// <summary>Method can add new elements to the collection.</summary>
UpdatedContent = ModifyExistingContent | 4 UpdatedContent = ModifyExistingContent | 4
} }
...@@ -856,14 +1024,16 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -856,14 +1024,16 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// <summary> /// <summary>
/// Indicates that the marked method is assertion method, i.e. it halts control flow if /// Indicates that the marked method is assertion method, i.e. it halts control flow if
/// one of the conditions is satisfied. To set the condition, mark one of the parameters with /// one of the conditions is satisfied. To set the condition, mark one of the parameters with
/// <see cref="AssertionConditionAttribute"/> attribute. /// <see cref="AssertionConditionAttribute" /> attribute.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class AssertionMethodAttribute : Attribute { } public sealed class AssertionMethodAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates the condition parameter of the assertion method. The method itself should be /// Indicates the condition parameter of the assertion method. The method itself should be
/// marked by <see cref="AssertionMethodAttribute"/> attribute. The mandatory argument of /// marked by <see cref="AssertionMethodAttribute" /> attribute. The mandatory argument of
/// the attribute is the assertion type. /// the attribute is the assertion type.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
...@@ -874,7 +1044,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -874,7 +1044,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
ConditionType = conditionType; ConditionType = conditionType;
} }
public AssertionConditionType ConditionType { get; private set; } public AssertionConditionType ConditionType { get; }
} }
/// <summary> /// <summary>
...@@ -885,12 +1055,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -885,12 +1055,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
{ {
/// <summary>Marked parameter should be evaluated to true.</summary> /// <summary>Marked parameter should be evaluated to true.</summary>
IS_TRUE = 0, IS_TRUE = 0,
/// <summary>Marked parameter should be evaluated to false.</summary> /// <summary>Marked parameter should be evaluated to false.</summary>
IS_FALSE = 1, IS_FALSE = 1,
/// <summary>Marked parameter should be evaluated to null value.</summary> /// <summary>Marked parameter should be evaluated to null value.</summary>
IS_NULL = 2, IS_NULL = 2,
/// <summary>Marked parameter should be evaluated to not null value.</summary> /// <summary>Marked parameter should be evaluated to not null value.</summary>
IS_NOT_NULL = 3, IS_NOT_NULL = 3
} }
/// <summary> /// <summary>
...@@ -899,7 +1072,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -899,7 +1072,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// </summary> /// </summary>
[Obsolete("Use [ContractAnnotation('=> halt')] instead")] [Obsolete("Use [ContractAnnotation('=> halt')] instead")]
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class TerminatesProgramAttribute : Attribute { } public sealed class TerminatesProgramAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select,
...@@ -907,19 +1082,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -907,19 +1082,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// of delegate type by analyzing LINQ method chains. /// of delegate type by analyzing LINQ method chains.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class LinqTunnelAttribute : Attribute { } public sealed class LinqTunnelAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that IEnumerable, passed as parameter, is not enumerated. /// Indicates that IEnumerable, passed as parameter, is not enumerated.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class NoEnumerationAttribute : Attribute { } public sealed class NoEnumerationAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Indicates that parameter is regular expression pattern. /// Indicates that parameter is regular expression pattern.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class RegexPatternAttribute : Attribute { } public sealed class RegexPatternAttribute : Attribute
{
}
/// <summary> /// <summary>
/// Prevents the Member Reordering feature from tossing members of the marked class. /// Prevents the Member Reordering feature from tossing members of the marked class.
...@@ -929,14 +1110,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -929,14 +1110,18 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// </remarks> /// </remarks>
[AttributeUsage( [AttributeUsage(
AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)]
public sealed class NoReorderAttribute : Attribute { } public sealed class NoReorderAttribute : Attribute
{
}
/// <summary> /// <summary>
/// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated /// 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. /// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public sealed class XamlItemsControlAttribute : Attribute { } public sealed class XamlItemsControlAttribute : Attribute
{
}
/// <summary> /// <summary>
/// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that /// XAML attribute. Indicates the property of some <c>BindingBase</c>-derived type, that
...@@ -945,10 +1130,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -945,10 +1130,12 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Property should have the tree ancestor of the <c>ItemsControl</c> type or /// Property should have the tree ancestor of the <c>ItemsControl</c> type or
/// marked with the <see cref="XamlItemsControlAttribute"/> attribute. /// marked with the <see cref="XamlItemsControlAttribute" /> attribute.
/// </remarks> /// </remarks>
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } public sealed class XamlItemBindingOfItemsControlAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class AspChildControlTypeAttribute : Attribute public sealed class AspChildControlTypeAttribute : Attribute
...@@ -959,19 +1146,27 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -959,19 +1146,27 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
ControlType = controlType; ControlType = controlType;
} }
[NotNull] public string TagName { get; private set; } [NotNull]
public string TagName { get; }
[NotNull] public Type ControlType { get; private set; } [NotNull]
public Type ControlType { get; }
} }
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
public sealed class AspDataFieldAttribute : Attribute { } public sealed class AspDataFieldAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
public sealed class AspDataFieldsAttribute : Attribute { } public sealed class AspDataFieldsAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public sealed class AspMethodPropertyAttribute : Attribute { } public sealed class AspMethodPropertyAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class AspRequiredAttributeAttribute : Attribute public sealed class AspRequiredAttributeAttribute : Attribute
...@@ -981,18 +1176,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -981,18 +1176,19 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Attribute = attribute; Attribute = attribute;
} }
[NotNull] public string Attribute { get; private set; } [NotNull]
public string Attribute { get; }
} }
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public sealed class AspTypePropertyAttribute : Attribute public sealed class AspTypePropertyAttribute : Attribute
{ {
public bool CreateConstructorReferences { get; private set; }
public AspTypePropertyAttribute(bool createConstructorReferences) public AspTypePropertyAttribute(bool createConstructorReferences)
{ {
CreateConstructorReferences = createConstructorReferences; CreateConstructorReferences = createConstructorReferences;
} }
public bool CreateConstructorReferences { get; }
} }
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
...@@ -1003,7 +1199,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -1003,7 +1199,8 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Name = name; Name = name;
} }
[NotNull] public string Name { get; private set; } [NotNull]
public string Name { get; }
} }
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
...@@ -1015,9 +1212,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -1015,9 +1212,11 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
FieldName = fieldName; FieldName = fieldName;
} }
[NotNull] public string Type { get; private set; } [NotNull]
public string Type { get; }
[NotNull] public string FieldName { get; private set; } [NotNull]
public string FieldName { get; }
} }
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
...@@ -1028,21 +1227,32 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations ...@@ -1028,21 +1227,32 @@ namespace Titanium.Web.Proxy.Examples.Wpf.Annotations
Directive = directive; Directive = directive;
} }
[NotNull] public string Directive { get; private set; } [NotNull]
public string Directive { get; }
} }
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class RazorHelperCommonAttribute : Attribute { } public sealed class RazorHelperCommonAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public sealed class RazorLayoutAttribute : Attribute { } public sealed class RazorLayoutAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class RazorWriteLiteralMethodAttribute : Attribute { } public sealed class RazorWriteLiteralMethodAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class RazorWriteMethodAttribute : Attribute { } public sealed class RazorWriteMethodAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public sealed class RazorWriteMethodParameterAttribute : Attribute { } public sealed class RazorWriteMethodParameterAttribute : Attribute
{
}
} }
using System.Reflection; using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
......
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> <SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles> <Profiles>
<Profile Name="(Default)" /> <Profile Name="(Default)" />
......
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Examples.Wpf.Annotations; using Titanium.Web.Proxy.Examples.Wpf.Annotations;
using Titanium.Web.Proxy.Http; using Titanium.Web.Proxy.Http;
...@@ -9,15 +8,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -9,15 +8,15 @@ namespace Titanium.Web.Proxy.Examples.Wpf
{ {
public class SessionListItem : INotifyPropertyChanged public class SessionListItem : INotifyPropertyChanged
{ {
private string statusCode;
private string protocol;
private string host;
private string url;
private long? bodySize; private long? bodySize;
private Exception exception;
private string host;
private string process; private string process;
private string protocol;
private long receivedDataCount; private long receivedDataCount;
private long sentDataCount; private long sentDataCount;
private Exception exception; private string statusCode;
private string url;
public int Number { get; set; } public int Number { get; set; }
...@@ -81,7 +80,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -81,7 +80,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
protected void SetField<T>(ref T field, T value,[CallerMemberName] string propertyName = null) protected void SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{ {
if (!Equals(field, value)) if (!Equals(field, value))
{ {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="StreamExtended" version="1.0.141-beta" targetFramework="net45" /> <package id="StreamExtended" version="1.0.141-beta" targetFramework="net45" />
</packages> </packages>
\ No newline at end of file
...@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.IntegrationTests ...@@ -35,7 +35,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
var handler = new HttpClientHandler var handler = new HttpClientHandler
{ {
Proxy = new WebProxy($"http://localhost:{localProxyPort}", false), Proxy = new WebProxy($"http://localhost:{localProxyPort}", false),
UseProxy = true, UseProxy = true
}; };
var client = new HttpClient(handler); var client = new HttpClient(handler);
...@@ -68,9 +68,11 @@ namespace Titanium.Web.Proxy.IntegrationTests ...@@ -68,9 +68,11 @@ namespace Titanium.Web.Proxy.IntegrationTests
proxyServer.Start(); proxyServer.Start();
foreach (var endPoint in proxyServer.ProxyEndPoints) foreach (var endPoint in proxyServer.ProxyEndPoints)
{
Console.WriteLine("Listening on '{0}' endpoint at Ip {1} and port: {2} ", Console.WriteLine("Listening on '{0}' endpoint at Ip {1} and port: {2} ",
endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port); endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port);
} }
}
public void Stop() public void Stop()
{ {
......
...@@ -27,6 +27,7 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -27,6 +27,7 @@ namespace Titanium.Web.Proxy.UnitTests
mgr.CertificateEngine = CertificateEngine.BouncyCastle; mgr.CertificateEngine = CertificateEngine.BouncyCastle;
mgr.ClearIdleCertificates(); mgr.ClearIdleCertificates();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{
foreach (string host in hostNames) foreach (string host in hostNames)
{ {
tasks.Add(Task.Run(() => tasks.Add(Task.Run(() =>
...@@ -36,6 +37,7 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -36,6 +37,7 @@ namespace Titanium.Web.Proxy.UnitTests
Assert.IsNotNull(certificate); Assert.IsNotNull(certificate);
})); }));
} }
}
await Task.WhenAll(tasks.ToArray()); await Task.WhenAll(tasks.ToArray());
...@@ -59,6 +61,7 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -59,6 +61,7 @@ namespace Titanium.Web.Proxy.UnitTests
mgr.ClearIdleCertificates(); mgr.ClearIdleCertificates();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{
foreach (string host in hostNames) foreach (string host in hostNames)
{ {
tasks.Add(Task.Run(() => tasks.Add(Task.Run(() =>
...@@ -68,6 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -68,6 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests
Assert.IsNotNull(certificate); Assert.IsNotNull(certificate);
})); }));
} }
}
await Task.WhenAll(tasks.ToArray()); await Task.WhenAll(tasks.ToArray());
mgr.RemoveTrustedRootCertificate(true); mgr.RemoveTrustedRootCertificate(true);
......
...@@ -9,7 +9,8 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -9,7 +9,8 @@ namespace Titanium.Web.Proxy.UnitTests
public class ProxyServerTests public class ProxyServerTests
{ {
[TestMethod] [TestMethod]
public void GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenExceptionIsThrown() public void
GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenExceptionIsThrown()
{ {
// Arrange // Arrange
var proxy = new ProxyServer(); var proxy = new ProxyServer();
...@@ -34,7 +35,8 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -34,7 +35,8 @@ namespace Titanium.Web.Proxy.UnitTests
} }
[TestMethod] [TestMethod]
public void GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenTwoEndpointsExists() public void
GivenOneEndpointIsAlreadyAddedToAddress_WhenAddingNewEndpointToExistingAddress_ThenTwoEndpointsExists()
{ {
// Arrange // Arrange
var proxy = new ProxyServer(); var proxy = new ProxyServer();
...@@ -74,7 +76,8 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -74,7 +76,8 @@ namespace Titanium.Web.Proxy.UnitTests
} }
[TestMethod] [TestMethod]
public void GivenOneEndpointIsAlreadyAddedToZeroPort_WhenAddingNewEndpointToExistingPort_ThenTwoEndpointsExists() public void
GivenOneEndpointIsAlreadyAddedToZeroPort_WhenAddingNewEndpointToExistingPort_ThenTwoEndpointsExists()
{ {
// Arrange // Arrange
var proxy = new ProxyServer(); var proxy = new ProxyServer();
......
...@@ -85,7 +85,9 @@ namespace Titanium.Web.Proxy.UnitTests ...@@ -85,7 +85,9 @@ namespace Titanium.Web.Proxy.UnitTests
{ {
hostName = Dns.GetHostName(); hostName = Dns.GetHostName();
} }
catch{} catch
{
}
if (hostName != null) if (hostName != null)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment