Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
7840a4b9
Commit
7840a4b9
authored
Apr 14, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup test/example projects
parent
000f3715
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1307 additions
and
1087 deletions
+1307
-1087
App.config
Examples/Titanium.Web.Proxy.Examples.Basic/App.config
+6
-5
ConsoleHelper.cs
...itanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs
+7
-7
AssemblyInfo.cs
...anium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs
+0
-1
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+13
-13
App.config
Examples/Titanium.Web.Proxy.Examples.Wpf/App.config
+6
-5
App.xaml
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml
+2
-2
App.xaml.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml.cs
+1
-1
MainWindow.xaml
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml
+45
-44
MainWindow.xaml.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+46
-48
Annotations.cs
...Titanium.Web.Proxy.Examples.Wpf/Properties/Annotations.cs
+1151
-941
AssemblyInfo.cs
...itanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs
+4
-6
Settings.settings
...anium.Web.Proxy.Examples.Wpf/Properties/Settings.settings
+1
-0
SessionListItem.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs
+6
-7
packages.config
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
+1
-0
SslTests.cs
Tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
+5
-3
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+4
-0
ProxyServerTests.cs
Tests/Titanium.Web.Proxy.UnitTests/ProxyServerTests.cs
+6
-3
SystemProxyTest.cs
Tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
+3
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/App.config
View file @
7840a4b9
<?
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
Examples/Titanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs
View file @
7840a4b9
...
@@ -4,24 +4,24 @@ using System.Runtime.InteropServices;
...
@@ -4,24 +4,24 @@ using System.Runtime.InteropServices;
namespace
Titanium.Web.Proxy.Examples.Basic.Helpers
namespace
Titanium.Web.Proxy.Examples.Basic.Helpers
{
{
/// <summary>
/// <summary>
/// Adapated from
///
Adapated from
/// http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
///
http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
/// </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
()
{
{
...
...
Examples/Titanium.Web.Proxy.Examples.Basic/Properties/AssemblyInfo.cs
View file @
7840a4b9
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
...
...
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
7840a4b9
...
@@ -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
))
...
@@ -251,7 +251,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -251,7 +251,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
}
/// <summary>
/// <summary>
/// Allows overriding default certificate validation logic
///
Allows overriding default certificate validation logic
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
@@ -267,7 +267,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -267,7 +267,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
}
}
/// <summary>
/// <summary>
/// Allows overriding default client certificate selection logic during mutual authentication
///
Allows overriding default client certificate selection logic during mutual authentication
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/App.config
View file @
7840a4b9
<?
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
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml
View file @
7840a4b9
...
@@ -4,6 +4,6 @@
...
@@ -4,6 +4,6 @@
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
StartupUri="MainWindow.xaml">
StartupUri="MainWindow.xaml">
<Application.Resources>
<Application.Resources>
</Application.Resources>
</Application.Resources>
</Application>
</Application>
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Wpf/App.xaml.cs
View file @
7840a4b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
namespace
Titanium.Web.Proxy.Examples.Wpf
namespace
Titanium.Web.Proxy.Examples.Wpf
{
{
/// <summary>
/// <summary>
/// Interaction logic for App.xaml
///
Interaction logic for App.xaml
/// </summary>
/// </summary>
public
partial
class
App
:
Application
public
partial
class
App
:
Application
{
{
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml
View file @
7840a4b9
...
@@ -6,50 +6,51 @@
...
@@ -6,50 +6,51 @@
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
xmlns:local="clr-namespace:Titanium.Web.Proxy.Examples.Wpf"
mc:Ignorable="d"
mc:Ignorable="d"
Title="MainWindow" Height="500" Width="1000" WindowState="Maximized"
Title="MainWindow" Height="500" Width="1000" WindowState="Maximized"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500" />
<ColumnDefinition Width="500" />
<ColumnDefinition Width="3" />
<ColumnDefinition Width="3" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<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}"
KeyDown="ListViewSessions_OnKeyDown">
SelectedItem="{Binding SelectedSession}"
<ListView.View>
KeyDown="ListViewSessions_OnKeyDown">
<GridView>
<ListView.View>
<GridViewColumn Header="Result" DisplayMemberBinding="{Binding StatusCode}" />
<GridView>
<GridViewColumn Header="Protocol" DisplayMemberBinding="{Binding Protocol}" />
<GridViewColumn Header="Result" DisplayMemberBinding="{Binding StatusCode}" />
<GridViewColumn Header="Host" DisplayMemberBinding="{Binding Host}" />
<GridViewColumn Header="Protocol" DisplayMemberBinding="{Binding Protocol}" />
<GridViewColumn Header="Url" DisplayMemberBinding="{Binding Url}" />
<GridViewColumn Header="Host" DisplayMemberBinding="{Binding Host}" />
<GridViewColumn Header="BodySize" DisplayMemberBinding="{Binding BodySize}" />
<GridViewColumn Header="Url" DisplayMemberBinding="{Binding Url}" />
<GridViewColumn Header="Process" DisplayMemberBinding="{Binding Process}" />
<GridViewColumn Header="BodySize" DisplayMemberBinding="{Binding BodySize}" />
<GridViewColumn Header="SentBytes" DisplayMemberBinding="{Binding SentDataCount}" />
<GridViewColumn Header="Process" DisplayMemberBinding="{Binding Process}" />
<GridViewColumn Header="ReceivedBytes" DisplayMemberBinding="{Binding ReceivedDataCount}" />
<GridViewColumn Header="SentBytes" DisplayMemberBinding="{Binding SentDataCount}" />
</GridView>
<GridViewColumn Header="ReceivedBytes" DisplayMemberBinding="{Binding ReceivedDataCount}" />
</ListView.View>
</GridView>
</ListView>
</ListView.View>
<TabControl Grid.Column="2" Grid.Row="0">
</ListView>
<TabItem Header="Session">
<TabControl Grid.Column="2" Grid.Row="0">
<Grid Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TabItem Header="Session">
<Grid.RowDefinitions>
<Grid Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<RowDefinition />
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<RowDefinition />
<TextBox x:Name="TextBoxRequest" Grid.Row="0" />
</Grid.RowDefinitions>
<TextBox x:Name="TextBoxResponse" Grid.Row="1" />
<TextBox x:Name="TextBoxRequest" Grid.Row="0" />
</Grid>
<TextBox x:Name="TextBoxResponse" Grid.Row="1" />
</TabItem>
</Grid>
</TabControl>
</TabItem>
<StackPanel Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
</TabControl>
<TextBlock Text="ClientConnectionCount:" />
<StackPanel Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock Text="{Binding ClientConnectionCount}" Margin="10,0,20,0" />
<TextBlock Text="ClientConnectionCount:" />
<TextBlock Text="ServerConnectionCount:" />
<TextBlock Text="{Binding ClientConnectionCount}" Margin="10,0,20,0" />
<TextBlock Text="{Binding ServerConnectionCount}" Margin="10,0,20,0" />
<TextBlock Text="ServerConnectionCount:" />
</StackPanel>
<TextBlock Text="{Binding ServerConnectionCount}" Margin="10,0,20,0" />
</StackPanel>
</Grid>
</Grid>
</Window>
</Window>
\ No newline at end of file
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
7840a4b9
...
@@ -16,48 +16,22 @@ using Titanium.Web.Proxy.Models;
...
@@ -16,48 +16,22 @@ using Titanium.Web.Proxy.Models;
namespace
Titanium.Web.Proxy.Examples.Wpf
namespace
Titanium.Web.Proxy.Examples.Wpf
{
{
/// <summary>
/// <summary>
/// Interaction logic for MainWindow.xaml
///
Interaction logic for MainWindow.xaml
/// </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
);
private
readonly
Dictionary
<
HttpWebClient
,
SessionListItem
>
sessionDictionary
=
set
=>
SetValue
(
ServerConnectionCountProperty
,
value
);
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
()
...
@@ -90,7 +64,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
...
@@ -90,7 +64,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
//proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword");
//proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword");
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
);
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
//proxyServer.UpStreamHttpProxy = new ExternalProxy
//proxyServer.UpStreamHttpProxy = new ExternalProxy
//{
//{
...
@@ -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
)
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/Properties/Annotations.cs
View file @
7840a4b9
...
@@ -32,1017 +32,1227 @@ using System;
...
@@ -32,1017 +32,1227 @@ using System;
namespace
Titanium.Web.Proxy.Examples.Wpf.Annotations
namespace
Titanium.Web.Proxy.Examples.Wpf.Annotations
{
{
/// <summary>
/// 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.
/// </summary>
/// <example><code>
/// [CanBeNull] object Test() => null;
///
/// void UseTest() {
/// var p = Test();
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
|
AttributeTargets
.
Event
|
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
GenericParameter
)]
public
sealed
class
CanBeNullAttribute
:
Attribute
{
}
/// <summary>
/// Indicates that the value of the marked element could never be <c>null</c>.
/// </summary>
/// <example><code>
/// [NotNull] object Foo() {
/// return null; // Warning: Possible 'null' assignment
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
|
AttributeTargets
.
Event
|
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
GenericParameter
)]
public
sealed
class
NotNullAttribute
:
Attribute
{
}
/// <summary>
/// Can be appplied 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
)]
public
sealed
class
ItemNotNullAttribute
:
Attribute
{
}
/// <summary>
/// Can be appplied 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
)]
public
sealed
class
ItemCanBeNullAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
/// <example><code>
/// [StringFormatMethod("message")]
/// void ShowError(string message, params object[] args) { /* do something */ }
///
/// void Foo() {
/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Constructor
|
AttributeTargets
.
Method
|
AttributeTargets
.
Property
|
AttributeTargets
.
Delegate
)]
public
sealed
class
StringFormatMethodAttribute
:
Attribute
{
/// <param name="formatParameterName">
/// Specifies which parameter of an annotated method should be treated as format-string
/// </param>
public
StringFormatMethodAttribute
([
NotNull
]
string
formatParameterName
)
{
FormatParameterName
=
formatParameterName
;
}
[
NotNull
]
public
string
FormatParameterName
{
get
;
private
set
;
}
}
/// <summary>
/// For a parameter that is expected to be one of the limited set of values.
/// Specify fields of which type should be used as values for this parameter.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Field
,
AllowMultiple
=
true
)]
public
sealed
class
ValueProviderAttribute
:
Attribute
{
public
ValueProviderAttribute
([
NotNull
]
string
name
)
{
Name
=
name
;
}
[
NotNull
]
public
string
Name
{
get
;
private
set
;
}
}
/// <summary>
/// Indicates that the function argument should be string literal and match one
/// of the parameters of the caller function. For example, ReSharper annotates
/// the parameter of <see cref="System.ArgumentNullException"/>.
/// </summary>
/// <example><code>
/// void Foo(string param) {
/// if (param == null)
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
InvokerParameterNameAttribute
:
Attribute
{
}
/// <summary>
/// Indicates that the method is contained in a type that implements
/// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
/// is used to notify that some property value changed.
/// </summary>
/// <remarks>
/// The method should be non-static and conform to one of the supported signatures:
/// <list>
/// <item><c>NotifyChanged(string)</c></item>
/// <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>
/// </remarks>
/// <example><code>
/// public class Foo : INotifyPropertyChanged {
/// public event PropertyChangedEventHandler PropertyChanged;
///
/// [NotifyPropertyChangedInvocator]
/// protected virtual void NotifyChanged(string propertyName) { ... }
///
/// string _name;
///
/// public string Name {
/// get { return _name; }
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
/// }
/// }
/// </code>
/// Examples of generated notifications:
/// <list>
/// <item><c>NotifyChanged("Property")</c></item>
/// <item><c>NotifyChanged(() => Property)</c></item>
/// <item><c>NotifyChanged((VM x) => x.Property)</c></item>
/// <item><c>SetProperty(ref myField, value, "Property")</c></item>
/// </list>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
NotifyPropertyChangedInvocatorAttribute
:
Attribute
{
public
NotifyPropertyChangedInvocatorAttribute
()
{
}
public
NotifyPropertyChangedInvocatorAttribute
([
NotNull
]
string
parameterName
)
{
ParameterName
=
parameterName
;
}
[
CanBeNull
]
public
string
ParameterName
{
get
;
private
set
;
}
}
/// <summary>
/// Describes dependency between method input and output.
/// </summary>
/// <syntax>
/// <p>Function Definition Table syntax:</p>
/// <list>
/// <item>FDT ::= FDTRow [;FDTRow]*</item>
/// <item>FDTRow ::= Input => Output | Output <= Input</item>
/// <item>Input ::= ParameterName: Value [, Input]*</item>
/// <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.<br/>
/// 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/>
/// 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
/// 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/>
/// </syntax>
/// <examples><list>
/// <item><code>
/// [ContractAnnotation("=> halt")]
/// public void TerminationMethod()
/// </code></item>
/// <item><code>
/// [ContractAnnotation("halt <= condition: false")]
/// public void Assert(bool condition, string text) // regular assertion method
/// </code></item>
/// <item><code>
/// [ContractAnnotation("s:null => true")]
/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
/// </code></item>
/// <item><code>
/// // 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)
/// </code></item>
/// <item><code>
/// [ContractAnnotation("=> true, result: notnull; => false, result: null")]
/// public bool TryParse(string s, out Person result)
/// </code></item>
/// </list></examples>
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
true
)]
public
sealed
class
ContractAnnotationAttribute
:
Attribute
{
public
ContractAnnotationAttribute
([
NotNull
]
string
contract
)
:
this
(
contract
,
false
)
{
}
public
ContractAnnotationAttribute
([
NotNull
]
string
contract
,
bool
forceFullStates
)
{
Contract
=
contract
;
ForceFullStates
=
forceFullStates
;
}
[
NotNull
]
public
string
Contract
{
get
;
private
set
;
}
public
bool
ForceFullStates
{
get
;
private
set
;
}
}
/// <summary>
/// Indicates that marked element should be localized or not.
/// </summary>
/// <example><code>
/// [LocalizationRequiredAttribute(true)]
/// class Foo {
/// string str = "my string"; // Warning: Localizable string
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
All
)]
public
sealed
class
LocalizationRequiredAttribute
:
Attribute
{
public
LocalizationRequiredAttribute
()
:
this
(
true
)
{
}
public
LocalizationRequiredAttribute
(
bool
required
)
{
Required
=
required
;
}
public
bool
Required
{
get
;
private
set
;
}
}
/// <summary>
/// Indicates that the value of the marked type (or its derivatives)
/// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
/// should be used instead. However, using '==' or '!=' for comparison
/// with <c>null</c> is always permitted.
/// </summary>
/// <example><code>
/// [CannotApplyEqualityOperator]
/// class NoEquality { }
///
/// class UsesNoEquality {
/// void Test() {
/// var ca1 = new NoEquality();
/// var ca2 = new NoEquality();
/// if (ca1 != null) { // OK
/// bool condition = ca1 == ca2; // Warning
/// }
/// }
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Interface
|
AttributeTargets
.
Class
|
AttributeTargets
.
Struct
)]
public
sealed
class
CannotApplyEqualityOperatorAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
/// <example><code>
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
/// class ComponentAttribute : Attribute { }
///
/// [Component] // ComponentAttribute requires implementing IComponent interface
/// class MyComponent : IComponent { }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
[
BaseTypeRequired
(
typeof
(
Attribute
))]
public
sealed
class
BaseTypeRequiredAttribute
:
Attribute
{
public
BaseTypeRequiredAttribute
([
NotNull
]
Type
baseType
)
{
BaseType
=
baseType
;
}
[
NotNull
]
public
Type
BaseType
{
get
;
private
set
;
}
}
/// <summary>
/// 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).
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
All
)]
public
sealed
class
UsedImplicitlyAttribute
:
Attribute
{
public
UsedImplicitlyAttribute
()
:
this
(
ImplicitUseKindFlags
.
Default
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
UsedImplicitlyAttribute
(
ImplicitUseKindFlags
useKindFlags
)
:
this
(
useKindFlags
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
UsedImplicitlyAttribute
(
ImplicitUseTargetFlags
targetFlags
)
:
this
(
ImplicitUseKindFlags
.
Default
,
targetFlags
)
{
}
public
UsedImplicitlyAttribute
(
ImplicitUseKindFlags
useKindFlags
,
ImplicitUseTargetFlags
targetFlags
)
{
UseKindFlags
=
useKindFlags
;
TargetFlags
=
targetFlags
;
}
public
ImplicitUseKindFlags
UseKindFlags
{
get
;
private
set
;
}
public
ImplicitUseTargetFlags
TargetFlags
{
get
;
private
set
;
}
}
/// <summary>
/// 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)
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Class
|
AttributeTargets
.
GenericParameter
)]
public
sealed
class
MeansImplicitUseAttribute
:
Attribute
{
public
MeansImplicitUseAttribute
()
:
this
(
ImplicitUseKindFlags
.
Default
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
MeansImplicitUseAttribute
(
ImplicitUseKindFlags
useKindFlags
)
:
this
(
useKindFlags
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
MeansImplicitUseAttribute
(
ImplicitUseTargetFlags
targetFlags
)
:
this
(
ImplicitUseKindFlags
.
Default
,
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
;
}
}
[
Flags
]
public
enum
ImplicitUseKindFlags
{
Default
=
Access
|
Assign
|
InstantiatedWithFixedConstructorSignature
,
/// <summary>Only entity marked with attribute considered used.</summary>
Access
=
1
,
/// <summary>Indicates implicit assignment to a member.</summary>
Assign
=
2
,
/// <summary>
/// <summary>
///
Indicates implicit instantiation of a type with fixed constructor signature.
///
Indicates that the value of the marked element could be <c>null</c> sometimes,
///
That means any unused constructor parameters won't be reported as such
.
///
so the check for <c>null</c> is necessary before its usage
.
/// </summary>
/// </summary>
InstantiatedWithFixedConstructorSignature
=
4
,
/// <example>
/// <summary>Indicates implicit instantiation of a type.</summary>
/// <code>
InstantiatedNoFixedConstructorSignature
=
8
,
/// [CanBeNull] object Test() => null;
}
///
/// void UseTest() {
/// <summary>
/// var p = Test();
/// Specify what is considered used implicitly when marked
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
/// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>.
/// }
/// </summary>
/// </code>
[
Flags
]
/// </example>
public
enum
ImplicitUseTargetFlags
[
AttributeUsage
(
{
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
Default
=
Itself
,
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
|
AttributeTargets
.
Event
|
Itself
=
1
,
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
GenericParameter
)]
/// <summary>Members of entity marked with attribute are considered used.</summary>
public
sealed
class
CanBeNullAttribute
:
Attribute
Members
=
2
,
{
/// <summary>Entity marked with attribute and all its members considered used.</summary>
}
WithMembers
=
Itself
|
Members
}
/// <summary>
/// Indicates that the value of the marked element could never be <c>null</c>.
/// <summary>
/// </summary>
/// This attribute is intended to mark publicly available API
/// <example>
/// which should not be removed and so is treated as used.
/// <code>
/// </summary>
/// [NotNull] object Foo() {
[
MeansImplicitUse
(
ImplicitUseTargetFlags
.
WithMembers
)]
/// return null; // Warning: Possible 'null' assignment
public
sealed
class
PublicAPIAttribute
:
Attribute
/// }
{
/// </code>
public
PublicAPIAttribute
()
{
}
/// </example>
[
AttributeUsage
(
public
PublicAPIAttribute
([
NotNull
]
string
comment
)
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
{
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
|
AttributeTargets
.
Event
|
Comment
=
comment
;
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
GenericParameter
)]
}
public
sealed
class
NotNullAttribute
:
Attribute
{
[
CanBeNull
]
public
string
Comment
{
get
;
private
set
;
}
}
}
/// <summary>
/// <summary>
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
/// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack.
/// and Lazy classes to indicate that the value of a collection item, of the Task.Result property
/// If the parameter is a delegate, indicates that delegate is executed while the method is executed.
/// or of the Lazy.Value property can never be null.
/// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
/// </summary>
/// </summary>
[
AttributeUsage
(
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
public
sealed
class
InstantHandleAttribute
:
Attribute
{
}
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
)]
public
sealed
class
ItemNotNullAttribute
:
Attribute
/// <summary>
{
/// Indicates that a method does not make any observable state changes.
}
/// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
/// </summary>
/// <summary>
/// <example><code>
/// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task
/// [Pure] int Multiply(int x, int y) => x * y;
/// 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.
/// void M() {
/// </summary>
/// Multiply(123, 42); // Waring: Return value of pure method is not used
[
AttributeUsage
(
/// }
AttributeTargets
.
Method
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
/// </code></example>
AttributeTargets
.
Delegate
|
AttributeTargets
.
Field
)]
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
ItemCanBeNullAttribute
:
Attribute
public
sealed
class
PureAttribute
:
Attribute
{
}
{
}
/// <summary>
/// Indicates that the return value of method invocation must be used.
/// <summary>
/// </summary>
/// Indicates that the marked method builds string by format pattern and (optional) arguments.
[
AttributeUsage
(
AttributeTargets
.
Method
)]
/// Parameter, which contains format string, should be given in constructor. The format string
public
sealed
class
MustUseReturnValueAttribute
:
Attribute
/// should be in <see cref="string.Format(IFormatProvider,string,object[])" />-like form.
{
/// </summary>
public
MustUseReturnValueAttribute
()
{
}
/// <example>
/// <code>
public
MustUseReturnValueAttribute
([
NotNull
]
string
justification
)
/// [StringFormatMethod("message")]
{
/// void ShowError(string message, params object[] args) { /* do something */ }
Justification
=
justification
;
///
}
/// void Foo() {
/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
[
CanBeNull
]
public
string
Justification
{
get
;
private
set
;
}
/// }
}
/// </code>
/// </example>
/// <summary>
[
AttributeUsage
(
/// Indicates the type member or parameter of some type, that should be used instead of all other ways
AttributeTargets
.
Constructor
|
AttributeTargets
.
Method
|
/// to get the value that type. This annotation is useful when you have some "context" value evaluated
AttributeTargets
.
Property
|
AttributeTargets
.
Delegate
)]
/// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one.
public
sealed
class
StringFormatMethodAttribute
:
Attribute
/// </summary>
{
/// <example><code>
/// <param name="formatParameterName">
/// class Foo {
/// Specifies which parameter of an annotated method should be treated as format-string
/// [ProvidesContext] IBarService _barService = ...;
/// </param>
///
public
StringFormatMethodAttribute
([
NotNull
]
string
formatParameterName
)
/// void ProcessNode(INode node) {
{
/// DoSomething(node, node.GetGlobalServices().Bar);
FormatParameterName
=
formatParameterName
;
/// // ^ Warning: use value of '_barService' field
}
/// }
/// }
[
NotNull
]
/// </code></example>
public
string
FormatParameterName
{
get
;
}
[
AttributeUsage
(
}
AttributeTargets
.
Field
|
AttributeTargets
.
Property
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
|
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
Struct
|
AttributeTargets
.
GenericParameter
)]
/// <summary>
public
sealed
class
ProvidesContextAttribute
:
Attribute
{
}
/// For a parameter that is expected to be one of the limited set of values.
/// Specify fields of which type should be used as values for this parameter.
/// <summary>
/// </summary>
/// Indicates that a parameter is a path to a file or a folder within a web project.
[
AttributeUsage
(
/// Path can be relative or absolute, starting from web root (~).
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Field
,
/// </summary>
AllowMultiple
=
true
)]
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
ValueProviderAttribute
:
Attribute
public
sealed
class
PathReferenceAttribute
:
Attribute
{
{
public
ValueProviderAttribute
([
NotNull
]
string
name
)
public
PathReferenceAttribute
()
{
}
{
Name
=
name
;
public
PathReferenceAttribute
([
NotNull
,
PathReference
]
string
basePath
)
}
{
BasePath
=
basePath
;
[
NotNull
]
}
public
string
Name
{
get
;
}
}
[
CanBeNull
]
public
string
BasePath
{
get
;
private
set
;
}
}
/// <summary>
/// Indicates that the function argument should be string literal and match one
/// <summary>
/// of the parameters of the caller function. For example, ReSharper annotates
/// An extension method marked with this attribute is processed by ReSharper code completion
/// the parameter of <see cref="System.ArgumentNullException" />.
/// as a 'Source Template'. When extension method is completed over some expression, it's source code
/// </summary>
/// is automatically expanded like a template at call site.
/// <example>
/// </summary>
/// <code>
/// <remarks>
/// void Foo(string param) {
/// Template method body can contain valid source code and/or special comments starting with '$'.
/// if (param == null)
/// Text inside these comments is added as source code when the template is applied. Template parameters
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// 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.
/// </code>
/// </remarks>
/// </example>
/// <example>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
/// In this example, the 'forEach' method is a source template available over all values
public
sealed
class
InvokerParameterNameAttribute
:
Attribute
/// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
{
/// <code>
}
/// [SourceTemplate]
/// public static void forEach<T>(this IEnumerable<T> xs) {
/// <summary>
/// foreach (var x in xs) {
/// Indicates that the method is contained in a type that implements
/// //$ $END$
/// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
/// }
/// is used to notify that some property value changed.
/// }
/// </summary>
/// </code>
/// <remarks>
/// </example>
/// The method should be non-static and conform to one of the supported signatures:
[
AttributeUsage
(
AttributeTargets
.
Method
)]
/// <list>
public
sealed
class
SourceTemplateAttribute
:
Attribute
{
}
/// <item>
/// <c>NotifyChanged(string)</c>
/// <summary>
/// </item>
/// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
/// <item>
/// </summary>
/// <c>NotifyChanged(params string[])</c>
/// <remarks>
/// </item>
/// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression
/// <item>
/// is defined in the <see cref="MacroAttribute.Expression"/> property. When applied on a method, the target
/// <c>NotifyChanged{T}(Expression{Func{T}})</c>
/// template parameter is defined in the <see cref="MacroAttribute.Target"/> property. To apply the macro silently
/// </item>
/// for the parameter, set the <see cref="MacroAttribute.Editable"/> property value = -1.
/// <item>
/// </remarks>
/// <c>NotifyChanged{T,U}(Expression{Func{T,U}})</c>
/// <example>
/// </item>
/// Applying the attribute on a source template method:
/// <item>
/// <code>
/// <c>SetProperty{T}(ref T, T, string)</c>
/// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
/// </item>
/// public static void forEach<T>(this IEnumerable<T> collection) {
/// </list>
/// foreach (var item in collection) {
/// </remarks>
/// //$ $END$
/// <example>
/// }
/// <code>
/// }
/// public class Foo : INotifyPropertyChanged {
/// </code>
/// public event PropertyChangedEventHandler PropertyChanged;
/// Applying the attribute on a template method parameter:
///
/// <code>
/// [NotifyPropertyChangedInvocator]
/// [SourceTemplate]
/// protected virtual void NotifyChanged(string propertyName) { ... }
/// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
///
/// /*$ var $x$Id = "$newguid$" + x.ToString();
/// string _name;
/// x.DoSomething($x$Id); */
///
/// }
/// public string Name {
/// </code>
/// get { return _name; }
/// </example>
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
,
AllowMultiple
=
true
)]
/// }
public
sealed
class
MacroAttribute
:
Attribute
/// }
{
/// </code>
/// Examples of generated notifications:
/// <list>
/// <item>
/// <c>NotifyChanged("Property")</c>
/// </item>
/// <item>
/// <c>NotifyChanged(() => Property)</c>
/// </item>
/// <item>
/// <c>NotifyChanged((VM x) => x.Property)</c>
/// </item>
/// <item>
/// <c>SetProperty(ref myField, value, "Property")</c>
/// </item>
/// </list>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
NotifyPropertyChangedInvocatorAttribute
:
Attribute
{
public
NotifyPropertyChangedInvocatorAttribute
()
{
}
public
NotifyPropertyChangedInvocatorAttribute
([
NotNull
]
string
parameterName
)
{
ParameterName
=
parameterName
;
}
[
CanBeNull
]
public
string
ParameterName
{
get
;
}
}
/// <summary>
/// Describes dependency between method input and output.
/// </summary>
/// <syntax>
/// <p>Function Definition Table syntax:</p>
/// <list>
/// <item>FDT ::= FDTRow [;FDTRow]*</item>
/// <item>FDTRow ::= Input => Output | Output <= Input</item>
/// <item>Input ::= ParameterName: Value [, Input]*</item>
/// <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.<br />
/// 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 />
/// 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
/// 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 />
/// </syntax>
/// <examples>
/// <list>
/// <item>
/// <code>
/// [ContractAnnotation("=> halt")]
/// public void TerminationMethod()
/// </code>
/// </item>
/// <item>
/// <code>
/// [ContractAnnotation("halt <= condition: false")]
/// public void Assert(bool condition, string text) // regular assertion method
/// </code>
/// </item>
/// <item>
/// <code>
/// [ContractAnnotation("s:null => true")]
/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
/// </code>
/// </item>
/// <item>
/// <code>
/// // 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)
/// </code>
/// </item>
/// <item>
/// <code>
/// [ContractAnnotation("=> true, result: notnull; => false, result: null")]
/// public bool TryParse(string s, out Person result)
/// </code>
/// </item>
/// </list>
/// </examples>
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
true
)]
public
sealed
class
ContractAnnotationAttribute
:
Attribute
{
public
ContractAnnotationAttribute
([
NotNull
]
string
contract
)
:
this
(
contract
,
false
)
{
}
public
ContractAnnotationAttribute
([
NotNull
]
string
contract
,
bool
forceFullStates
)
{
Contract
=
contract
;
ForceFullStates
=
forceFullStates
;
}
[
NotNull
]
public
string
Contract
{
get
;
}
public
bool
ForceFullStates
{
get
;
}
}
/// <summary>
/// Indicates that marked element should be localized or not.
/// </summary>
/// <example>
/// <code>
/// [LocalizationRequiredAttribute(true)]
/// class Foo {
/// string str = "my string"; // Warning: Localizable string
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
All
)]
public
sealed
class
LocalizationRequiredAttribute
:
Attribute
{
public
LocalizationRequiredAttribute
()
:
this
(
true
)
{
}
public
LocalizationRequiredAttribute
(
bool
required
)
{
Required
=
required
;
}
public
bool
Required
{
get
;
}
}
/// <summary>
/// Indicates that the value of the marked type (or its derivatives)
/// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
/// should be used instead. However, using '==' or '!=' for comparison
/// with <c>null</c> is always permitted.
/// </summary>
/// <example>
/// <code>
/// [CannotApplyEqualityOperator]
/// class NoEquality { }
///
/// class UsesNoEquality {
/// void Test() {
/// var ca1 = new NoEquality();
/// var ca2 = new NoEquality();
/// if (ca1 != null) { // OK
/// bool condition = ca1 == ca2; // Warning
/// }
/// }
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Interface
|
AttributeTargets
.
Class
|
AttributeTargets
.
Struct
)]
public
sealed
class
CannotApplyEqualityOperatorAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
/// <example>
/// <code>
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
/// class ComponentAttribute : Attribute { }
///
/// [Component] // ComponentAttribute requires implementing IComponent interface
/// class MyComponent : IComponent { }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
[
BaseTypeRequired
(
typeof
(
Attribute
))]
public
sealed
class
BaseTypeRequiredAttribute
:
Attribute
{
public
BaseTypeRequiredAttribute
([
NotNull
]
Type
baseType
)
{
BaseType
=
baseType
;
}
[
NotNull
]
public
Type
BaseType
{
get
;
}
}
/// <summary>
/// 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).
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
All
)]
public
sealed
class
UsedImplicitlyAttribute
:
Attribute
{
public
UsedImplicitlyAttribute
()
:
this
(
ImplicitUseKindFlags
.
Default
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
UsedImplicitlyAttribute
(
ImplicitUseKindFlags
useKindFlags
)
:
this
(
useKindFlags
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
UsedImplicitlyAttribute
(
ImplicitUseTargetFlags
targetFlags
)
:
this
(
ImplicitUseKindFlags
.
Default
,
targetFlags
)
{
}
public
UsedImplicitlyAttribute
(
ImplicitUseKindFlags
useKindFlags
,
ImplicitUseTargetFlags
targetFlags
)
{
UseKindFlags
=
useKindFlags
;
TargetFlags
=
targetFlags
;
}
public
ImplicitUseKindFlags
UseKindFlags
{
get
;
}
public
ImplicitUseTargetFlags
TargetFlags
{
get
;
}
}
/// <summary>
/// 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)
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Class
|
AttributeTargets
.
GenericParameter
)]
public
sealed
class
MeansImplicitUseAttribute
:
Attribute
{
public
MeansImplicitUseAttribute
()
:
this
(
ImplicitUseKindFlags
.
Default
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
MeansImplicitUseAttribute
(
ImplicitUseKindFlags
useKindFlags
)
:
this
(
useKindFlags
,
ImplicitUseTargetFlags
.
Default
)
{
}
public
MeansImplicitUseAttribute
(
ImplicitUseTargetFlags
targetFlags
)
:
this
(
ImplicitUseKindFlags
.
Default
,
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
;
}
}
[
Flags
]
public
enum
ImplicitUseKindFlags
{
Default
=
Access
|
Assign
|
InstantiatedWithFixedConstructorSignature
,
/// <summary>Only entity marked with attribute considered used.</summary>
Access
=
1
,
/// <summary>Indicates implicit assignment to a member.</summary>
Assign
=
2
,
/// <summary>
/// Indicates implicit instantiation of a type with fixed constructor signature.
/// That means any unused constructor parameters won't be reported as such.
/// </summary>
InstantiatedWithFixedConstructorSignature
=
4
,
/// <summary>Indicates implicit instantiation of a type.</summary>
InstantiatedNoFixedConstructorSignature
=
8
}
/// <summary>
/// Specify what is considered used implicitly when marked
/// with <see cref="MeansImplicitUseAttribute" /> or <see cref="UsedImplicitlyAttribute" />.
/// </summary>
[
Flags
]
public
enum
ImplicitUseTargetFlags
{
Default
=
Itself
,
Itself
=
1
,
/// <summary>Members of entity marked with attribute are considered used.</summary>
Members
=
2
,
/// <summary>Entity marked with attribute and all its members considered used.</summary>
WithMembers
=
Itself
|
Members
}
/// <summary>
/// This attribute is intended to mark publicly available API
/// which should not be removed and so is treated as used.
/// </summary>
[
MeansImplicitUse
(
ImplicitUseTargetFlags
.
WithMembers
)]
public
sealed
class
PublicAPIAttribute
:
Attribute
{
public
PublicAPIAttribute
()
{
}
public
PublicAPIAttribute
([
NotNull
]
string
comment
)
{
Comment
=
comment
;
}
[
CanBeNull
]
public
string
Comment
{
get
;
}
}
/// <summary>
/// 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
InstantHandleAttribute
:
Attribute
{
}
/// <summary>
/// <summary>
///
Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
///
Indicates that a method does not make any observable state changes.
///
parameter when the template is expanded
.
///
The same as <c>System.Diagnostics.Contracts.PureAttribute</c>
.
/// </summary>
/// </summary>
[
CanBeNull
]
public
string
Expression
{
get
;
set
;
}
/// <example>
/// <code>
/// [Pure] int Multiply(int x, int y) => x * y;
///
/// void M() {
/// Multiply(123, 42); // Waring: Return value of pure method is not used
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
PureAttribute
:
Attribute
{
}
/// <summary>
/// Indicates that the return value of method invocation must be used.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
MustUseReturnValueAttribute
:
Attribute
{
public
MustUseReturnValueAttribute
()
{
}
public
MustUseReturnValueAttribute
([
NotNull
]
string
justification
)
{
Justification
=
justification
;
}
[
CanBeNull
]
public
string
Justification
{
get
;
}
}
/// <summary>
/// <summary>
/// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
/// Indicates the type member or parameter of some type, that should be used instead of all other ways
/// 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.
/// </summary>
/// <example>
/// <code>
/// class Foo {
/// [ProvidesContext] IBarService _barService = ...;
///
/// void ProcessNode(INode node) {
/// DoSomething(node, node.GetGlobalServices().Bar);
/// // ^ Warning: use value of '_barService' field
/// }
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Field
|
AttributeTargets
.
Property
|
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
|
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
Struct
|
AttributeTargets
.
GenericParameter
)]
public
sealed
class
ProvidesContextAttribute
:
Attribute
{
}
/// <summary>
/// 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 (~).
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
PathReferenceAttribute
:
Attribute
{
public
PathReferenceAttribute
()
{
}
public
PathReferenceAttribute
([
NotNull
]
[
PathReference
]
string
basePath
)
{
BasePath
=
basePath
;
}
[
CanBeNull
]
public
string
BasePath
{
get
;
}
}
/// <summary>
/// An extension method marked with this attribute is processed by ReSharper code completion
/// as a 'Source Template'. When extension method is completed over some expression, it's source code
/// is automatically expanded like a template at call site.
/// </summary>
/// </summary>
/// <remarks>
/// <remarks>
/// If the target parameter is used several times in the template, only one occurrence becomes editable;
/// Template method body can contain valid source code and/or special comments starting with '$'.
/// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,
/// Text inside these comments is added as source code when the template is applied. Template parameters
/// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
/// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
/// </remarks>>
/// Use the <see cref="MacroAttribute" /> attribute to specify macros for parameters.
public
int
Editable
{
get
;
set
;
}
/// </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:
/// <code>
/// [SourceTemplate]
/// public static void forEach<T>(this IEnumerable<T> xs) {
/// foreach (var x in xs) {
/// //$ $END$
/// }
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
SourceTemplateAttribute
:
Attribute
{
}
/// <summary>
/// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
/// </summary>
/// <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:
/// <code>
/// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
/// public static void forEach<T>(this IEnumerable<T> collection) {
/// foreach (var item in collection) {
/// //$ $END$
/// }
/// }
/// </code>
/// Applying the attribute on a template method parameter:
/// <code>
/// [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); */
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
,
AllowMultiple
=
true
)]
public
sealed
class
MacroAttribute
:
Attribute
{
/// <summary>
/// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
/// parameter when the template is expanded.
/// </summary>
[
CanBeNull
]
public
string
Expression
{
get
;
set
;
}
/// <summary>
/// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
/// </summary>
/// <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
;
}
/// <summary>
/// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
/// <see cref="MacroAttribute" /> is applied on a template method.
/// </summary>
[
CanBeNull
]
public
string
Target
{
get
;
set
;
}
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
public
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
)]
public
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
)]
public
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
)]
public
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
)]
public
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
)]
public
sealed
class
AspMvcViewLocationFormatAttribute
:
Attribute
{
public
AspMvcViewLocationFormatAttribute
([
NotNull
]
string
format
)
{
Format
=
format
;
}
[
NotNull
]
public
string
Format
{
get
;
}
}
/// <summary>
/// <summary>
/// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// <see cref="MacroAttribute"/> is applied on a template method.
/// 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>.
/// </summary>
/// </summary>
[
CanBeNull
]
public
string
Target
{
get
;
set
;
}
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
}
public
sealed
class
AspMvcActionAttribute
:
Attribute
{
public
AspMvcActionAttribute
()
{
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
public
AspMvcActionAttribute
([
NotNull
]
string
anonymousProperty
)
public
sealed
class
AspMvcAreaMasterLocationFormatAttribute
:
Attribute
{
{
AnonymousProperty
=
anonymousProperty
;
public
AspMvcAreaMasterLocationFormatAttribute
([
NotNull
]
string
format
)
}
[
CanBeNull
]
public
string
AnonymousProperty
{
get
;
}
}
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcAreaAttribute
:
Attribute
{
{
Format
=
format
;
public
AspMvcAreaAttribute
()
{
}
public
AspMvcAreaAttribute
([
NotNull
]
string
anonymousProperty
)
{
AnonymousProperty
=
anonymousProperty
;
}
[
CanBeNull
]
public
string
AnonymousProperty
{
get
;
}
}
}
[
NotNull
]
public
string
Format
{
get
;
private
set
;
}
/// <summary>
}
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcControllerAttribute
:
Attribute
{
public
AspMvcControllerAttribute
()
{
}
public
AspMvcControllerAttribute
([
NotNull
]
string
anonymousProperty
)
{
AnonymousProperty
=
anonymousProperty
;
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
[
CanBeNull
]
public
sealed
class
AspMvcAreaPartialViewLocationFormatAttribute
:
Attribute
public
string
AnonymousProperty
{
get
;
}
{
}
public
AspMvcAreaPartialViewLocationFormatAttribute
([
NotNull
]
string
format
)
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute
/// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcMasterAttribute
:
Attribute
{
{
Format
=
format
;
}
}
[
NotNull
]
public
string
Format
{
get
;
private
set
;
}
/// <summary>
}
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcModelTypeAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
/// <summary>
public
sealed
class
AspMvcAreaViewLocationFormatAttribute
:
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
public
AspMvcAreaViewLocationFormatAttribute
([
NotNull
]
string
format
)
/// from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcPartialViewAttribute
:
Attribute
{
{
Format
=
format
;
}
}
[
NotNull
]
public
string
Format
{
get
;
private
set
;
}
/// <summary>
}
/// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Class
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcSuppressViewErrorAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
/// <summary>
public
sealed
class
AspMvcMasterLocationFormatAttribute
:
Attribute
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
{
/// Use this attribute for custom wrappers similar to
public
AspMvcMasterLocationFormatAttribute
([
NotNull
]
string
format
)
/// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcDisplayTemplateAttribute
:
Attribute
{
{
Format
=
format
;
}
}
[
NotNull
]
public
string
Format
{
get
;
private
set
;
}
/// <summary>
}
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcEditorTemplateAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
/// <summary>
public
sealed
class
AspMvcPartialViewLocationFormatAttribute
:
Attribute
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
{
/// Use this attribute for custom wrappers similar to
public
AspMvcPartialViewLocationFormatAttribute
([
NotNull
]
string
format
)
/// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcTemplateAttribute
:
Attribute
{
{
Format
=
format
;
}
}
[
NotNull
]
public
string
Format
{
get
;
private
set
;
}
/// <summary>
}
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcViewAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
,
AllowMultiple
=
true
)]
/// <summary>
public
sealed
class
AspMvcViewLocationFormatAttribute
:
Attribute
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
{
/// is an MVC view component name.
public
AspMvcViewLocationFormatAttribute
([
NotNull
]
string
format
)
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcViewComponentAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcViewComponentViewAttribute
:
Attribute
{
}
/// <summary>
/// ASP.NET MVC attribute. When applied to a parameter of an attribute,
/// indicates that this parameter is an MVC action name.
/// </summary>
/// <example>
/// <code>
/// [ActionName("Foo")]
/// public ActionResult Login(string returnUrl) {
/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
/// return RedirectToAction("Bar"); // Error: Cannot resolve action
/// }
/// </code>
/// </example>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
)]
public
sealed
class
AspMvcActionSelectorAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Field
)]
public
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
)]
public
sealed
class
HtmlAttributeValueAttribute
:
Attribute
{
public
HtmlAttributeValueAttribute
([
NotNull
]
string
name
)
{
Name
=
name
;
}
[
NotNull
]
public
string
Name
{
get
;
}
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
RazorSectionAttribute
:
Attribute
{
}
/// <summary>
/// Indicates how method, constructor invocation or property access
/// over collection type affects content of the collection.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
|
AttributeTargets
.
Constructor
|
AttributeTargets
.
Property
)]
public
sealed
class
CollectionAccessAttribute
:
Attribute
{
{
Format
=
format
;
public
CollectionAccessAttribute
(
CollectionAccessType
collectionAccessType
)
{
CollectionAccessType
=
collectionAccessType
;
}
public
CollectionAccessType
CollectionAccessType
{
get
;
}
}
}
[
NotNull
]
public
string
Format
{
get
;
private
set
;
}
[
Flags
]
}
public
enum
CollectionAccessType
{
/// <summary>Method does not use or modify content of the collection.</summary>
None
=
0
,
/// <summary>Method only reads content of the collection but does not modify it.</summary>
Read
=
1
,
/// <summary>Method can change content of the collection but does not add new elements.</summary>
ModifyExistingContent
=
2
,
/// <summary>
/// <summary>Method can add new elements to the collection.</summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
UpdatedContent
=
ModifyExistingContent
|
4
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcActionAttribute
:
Attribute
{
public
AspMvcActionAttribute
()
{
}
public
AspMvcActionAttribute
([
NotNull
]
string
anonymousProperty
)
/// <summary>
/// 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
/// <see cref="AssertionConditionAttribute" /> attribute.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
AssertionMethodAttribute
:
Attribute
{
{
AnonymousProperty
=
anonymousProperty
;
}
}
[
CanBeNull
]
public
string
AnonymousProperty
{
get
;
private
set
;
}
/// <summary>
}
/// 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AssertionConditionAttribute
:
Attribute
{
public
AssertionConditionAttribute
(
AssertionConditionType
conditionType
)
{
ConditionType
=
conditionType
;
}
/// <summary>
public
AssertionConditionType
ConditionType
{
get
;
}
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
}
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcAreaAttribute
:
Attribute
{
public
AspMvcAreaAttribute
()
{
}
public
AspMvcAreaAttribute
([
NotNull
]
string
anonymousProperty
)
/// <summary>
{
/// Specifies assertion type. If the assertion method argument satisfies the condition,
AnonymousProperty
=
anonymousProperty
;
/// then the execution continues. Otherwise, execution is assumed to be halted.
/// </summary>
public
enum
AssertionConditionType
{
/// <summary>Marked parameter should be evaluated to true.</summary>
IS_TRUE
=
0
,
/// <summary>Marked parameter should be evaluated to false.</summary>
IS_FALSE
=
1
,
/// <summary>Marked parameter should be evaluated to null value.</summary>
IS_NULL
=
2
,
/// <summary>Marked parameter should be evaluated to not null value.</summary>
IS_NOT_NULL
=
3
}
}
[
CanBeNull
]
public
string
AnonymousProperty
{
get
;
private
set
;
}
/// <summary>
}
/// Indicates that the marked method unconditionally terminates control flow execution.
/// For example, it could unconditionally throw exception.
/// <summary>
/// </summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
[
Obsolete
(
"Use [ContractAnnotation('=> halt')] instead"
)]
/// an MVC controller. If applied to a method, the MVC controller name is calculated
[
AttributeUsage
(
AttributeTargets
.
Method
)]
/// implicitly from the context. Use this attribute for custom wrappers similar to
public
sealed
class
TerminatesProgramAttribute
:
Attribute
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
{
/// </summary>
}
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcControllerAttribute
:
Attribute
{
public
AspMvcControllerAttribute
()
{
}
public
AspMvcControllerAttribute
([
NotNull
]
string
anonymousProperty
)
{
AnonymousProperty
=
anonymousProperty
;
}
[
CanBeNull
]
public
string
AnonymousProperty
{
get
;
private
set
;
}
}
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute
/// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcMasterAttribute
:
Attribute
{
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcModelTypeAttribute
:
Attribute
{
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcPartialViewAttribute
:
Attribute
{
}
/// <summary>
/// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Class
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcSuppressViewErrorAttribute
:
Attribute
{
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcDisplayTemplateAttribute
:
Attribute
{
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcEditorTemplateAttribute
:
Attribute
{
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcTemplateAttribute
:
Attribute
{
}
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcViewAttribute
:
Attribute
{
}
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// is an MVC view component name.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AspMvcViewComponentAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
AspMvcViewComponentViewAttribute
:
Attribute
{
}
/// <summary>
/// ASP.NET MVC attribute. When applied to a parameter of an attribute,
/// indicates that this parameter is an MVC action name.
/// </summary>
/// <example><code>
/// [ActionName("Foo")]
/// public ActionResult Login(string returnUrl) {
/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
/// return RedirectToAction("Bar"); // Error: Cannot resolve action
/// }
/// </code></example>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
)]
public
sealed
class
AspMvcActionSelectorAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Property
|
AttributeTargets
.
Field
)]
public
sealed
class
HtmlElementAttributesAttribute
:
Attribute
{
public
HtmlElementAttributesAttribute
()
{
}
public
HtmlElementAttributesAttribute
([
NotNull
]
string
name
)
{
Name
=
name
;
}
[
CanBeNull
]
public
string
Name
{
get
;
private
set
;
}
}
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Field
|
AttributeTargets
.
Property
)]
public
sealed
class
HtmlAttributeValueAttribute
:
Attribute
{
public
HtmlAttributeValueAttribute
([
NotNull
]
string
name
)
{
Name
=
name
;
}
[
NotNull
]
public
string
Name
{
get
;
private
set
;
}
}
/// <summary>
/// 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>.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
|
AttributeTargets
.
Method
)]
public
sealed
class
RazorSectionAttribute
:
Attribute
{
}
/// <summary>
/// Indicates how method, constructor invocation or property access
/// over collection type affects content of the collection.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
|
AttributeTargets
.
Constructor
|
AttributeTargets
.
Property
)]
public
sealed
class
CollectionAccessAttribute
:
Attribute
{
public
CollectionAccessAttribute
(
CollectionAccessType
collectionAccessType
)
{
CollectionAccessType
=
collectionAccessType
;
}
public
CollectionAccessType
CollectionAccessType
{
get
;
private
set
;
}
}
[
Flags
]
public
enum
CollectionAccessType
{
/// <summary>Method does not use or modify content of the collection.</summary>
None
=
0
,
/// <summary>Method only reads content of the collection but does not modify it.</summary>
Read
=
1
,
/// <summary>Method can change content of the collection but does not add new elements.</summary>
ModifyExistingContent
=
2
,
/// <summary>Method can add new elements to the collection.</summary>
UpdatedContent
=
ModifyExistingContent
|
4
}
/// <summary>
/// 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
/// <see cref="AssertionConditionAttribute"/> attribute.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
AssertionMethodAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
AssertionConditionAttribute
:
Attribute
{
public
AssertionConditionAttribute
(
AssertionConditionType
conditionType
)
{
ConditionType
=
conditionType
;
}
public
AssertionConditionType
ConditionType
{
get
;
private
set
;
}
}
/// <summary>
/// Specifies assertion type. If the assertion method argument satisfies the condition,
/// then the execution continues. Otherwise, execution is assumed to be halted.
/// </summary>
public
enum
AssertionConditionType
{
/// <summary>Marked parameter should be evaluated to true.</summary>
IS_TRUE
=
0
,
/// <summary>Marked parameter should be evaluated to false.</summary>
IS_FALSE
=
1
,
/// <summary>Marked parameter should be evaluated to null value.</summary>
IS_NULL
=
2
,
/// <summary>Marked parameter should be evaluated to not null value.</summary>
IS_NOT_NULL
=
3
,
}
/// <summary>
/// Indicates that the marked method unconditionally terminates control flow execution.
/// For example, it could unconditionally throw exception.
/// </summary>
[
Obsolete
(
"Use [ContractAnnotation('=> halt')] instead"
)]
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
TerminatesProgramAttribute
:
Attribute
{
}
/// <summary>
/// Indicates that method is 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
LinqTunnelAttribute
:
Attribute
{
}
/// <summary>
/// Indicates that IEnumerable, passed as parameter, is not enumerated.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
NoEnumerationAttribute
:
Attribute
{
}
/// <summary>
/// Indicates that parameter is regular expression pattern.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
RegexPatternAttribute
:
Attribute
{
}
/// <summary>
/// Prevents the Member Reordering feature from tossing members of the marked class.
/// </summary>
/// <remarks>
/// The attribute must be mentioned in your member reordering patterns
/// </remarks>
[
AttributeUsage
(
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
Struct
|
AttributeTargets
.
Enum
)]
public
sealed
class
NoReorderAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Class
)]
public
sealed
class
XamlItemsControlAttribute
:
Attribute
{
}
/// <summary>
/// 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.
/// </summary>
/// <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
)]
public
sealed
class
XamlItemBindingOfItemsControlAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
public
sealed
class
AspChildControlTypeAttribute
:
Attribute
{
public
AspChildControlTypeAttribute
([
NotNull
]
string
tagName
,
[
NotNull
]
Type
controlType
)
{
TagName
=
tagName
;
ControlType
=
controlType
;
}
[
NotNull
]
public
string
TagName
{
get
;
private
set
;
}
[
NotNull
]
public
Type
ControlType
{
get
;
private
set
;
}
/// <summary>
}
/// Indicates that method is 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.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Method
)]
public
sealed
class
LinqTunnelAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Method
)]
/// <summary>
public
sealed
class
AspDataFieldAttribute
:
Attribute
{
}
/// Indicates that IEnumerable, passed as parameter, is not enumerated.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
NoEnumerationAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Method
)]
/// <summary>
public
sealed
class
AspDataFieldsAttribute
:
Attribute
{
}
/// Indicates that parameter is regular expression pattern.
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Parameter
)]
public
sealed
class
RegexPatternAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Property
)]
/// <summary>
public
sealed
class
AspMethodPropertyAttribute
:
Attribute
{
}
/// Prevents the Member Reordering feature from tossing members of the marked class.
/// </summary>
/// <remarks>
/// The attribute must be mentioned in your member reordering patterns
/// </remarks>
[
AttributeUsage
(
AttributeTargets
.
Class
|
AttributeTargets
.
Interface
|
AttributeTargets
.
Struct
|
AttributeTargets
.
Enum
)]
public
sealed
class
NoReorderAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
/// <summary>
public
sealed
class
AspRequiredAttributeAttribute
:
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.
public
AspRequiredAttributeAttribute
([
NotNull
]
string
attribute
)
/// </summary>
{
[
AttributeUsage
(
AttributeTargets
.
Class
)]
Attribute
=
attribute
;
public
sealed
class
XamlItemsControlAttribute
:
Attribute
{
}
}
[
NotNull
]
public
string
Attribute
{
get
;
private
set
;
}
/// <summary>
}
/// 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.
/// </summary>
/// <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
)]
public
sealed
class
XamlItemBindingOfItemsControlAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Property
)]
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
public
sealed
class
AspTypePropertyAttribute
:
Attribute
public
sealed
class
AspChildControlTypeAttribute
:
Attribute
{
{
public
bool
CreateConstructorReferences
{
get
;
private
set
;
}
public
AspChildControlTypeAttribute
([
NotNull
]
string
tagName
,
[
NotNull
]
Type
controlType
)
{
TagName
=
tagName
;
ControlType
=
controlType
;
}
public
AspTypePropertyAttribute
(
bool
createConstructorReferences
)
[
NotNull
]
public
string
TagName
{
get
;
}
[
NotNull
]
public
Type
ControlType
{
get
;
}
}
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Method
)]
public
sealed
class
AspDataFieldAttribute
:
Attribute
{
{
CreateConstructorReferences
=
createConstructorReferences
;
}
}
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
AllowMultiple
=
true
)]
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Method
)]
public
sealed
class
RazorImportNamespaceAttribute
:
Attribute
public
sealed
class
AspDataFieldsAttribute
:
Attribute
{
public
RazorImportNamespaceAttribute
([
NotNull
]
string
name
)
{
{
Name
=
name
;
}
}
[
NotNull
]
public
string
Name
{
get
;
private
set
;
}
[
AttributeUsage
(
AttributeTargets
.
Property
)]
}
public
sealed
class
AspMethodPropertyAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
AllowMultiple
=
true
)]
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
public
sealed
class
RazorInjectionAttribute
:
Attribute
public
sealed
class
AspRequiredAttributeAttribute
:
Attribute
{
public
RazorInjectionAttribute
([
NotNull
]
string
type
,
[
NotNull
]
string
fieldName
)
{
{
Type
=
type
;
public
AspRequiredAttributeAttribute
([
NotNull
]
string
attribute
)
FieldName
=
fieldName
;
{
Attribute
=
attribute
;
}
[
NotNull
]
public
string
Attribute
{
get
;
}
}
}
[
NotNull
]
public
string
Type
{
get
;
private
set
;
}
[
AttributeUsage
(
AttributeTargets
.
Property
)]
public
sealed
class
AspTypePropertyAttribute
:
Attribute
{
public
AspTypePropertyAttribute
(
bool
createConstructorReferences
)
{
CreateConstructorReferences
=
createConstructorReferences
;
}
[
NotNull
]
public
string
FieldName
{
get
;
private
s
et
;
}
public
bool
CreateConstructorReferences
{
g
et
;
}
}
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
AllowMultiple
=
true
)]
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
AllowMultiple
=
true
)]
public
sealed
class
RazorDirectiveAttribute
:
Attribute
public
sealed
class
RazorImportNamespaceAttribute
:
Attribute
{
public
RazorDirectiveAttribute
([
NotNull
]
string
directive
)
{
{
Directive
=
directive
;
public
RazorImportNamespaceAttribute
([
NotNull
]
string
name
)
{
Name
=
name
;
}
[
NotNull
]
public
string
Name
{
get
;
}
}
}
[
NotNull
]
public
string
Directive
{
get
;
private
set
;
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
AllowMultiple
=
true
)]
}
public
sealed
class
RazorInjectionAttribute
:
Attribute
{
public
RazorInjectionAttribute
([
NotNull
]
string
type
,
[
NotNull
]
string
fieldName
)
{
Type
=
type
;
FieldName
=
fieldName
;
}
[
NotNull
]
public
string
Type
{
get
;
}
[
AttributeUsage
(
AttributeTargets
.
Method
)]
[
NotNull
]
public
sealed
class
RazorHelperCommonAttribute
:
Attribute
{
}
public
string
FieldName
{
get
;
}
}
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
AllowMultiple
=
true
)]
public
sealed
class
RazorDirectiveAttribute
:
Attribute
{
public
RazorDirectiveAttribute
([
NotNull
]
string
directive
)
{
Directive
=
directive
;
}
[
NotNull
]
public
string
Directive
{
get
;
}
}
[
AttributeUsage
(
AttributeTargets
.
Method
)]
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
}
{
\ No newline at end of file
}
}
Examples/Titanium.Web.Proxy.Examples.Wpf/Properties/AssemblyInfo.cs
View file @
7840a4b9
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
;
...
@@ -33,11 +31,11 @@ using System.Windows;
...
@@ -33,11 +31,11 @@ using System.Windows;
[
assembly
:
ThemeInfo
(
[
assembly
:
ThemeInfo
(
ResourceDictionaryLocation
.
None
,
//where theme specific resource dictionaries are located
ResourceDictionaryLocation
.
None
,
//where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
//(used if a resource is not found in the page,
// or application resource dictionaries)
// or application resource dictionaries)
ResourceDictionaryLocation
.
SourceAssembly
//where the generic resource dictionary is located
ResourceDictionaryLocation
.
SourceAssembly
//where the generic resource dictionary is located
//(used if a resource is not found in the page,
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
// app, or any theme specific resource dictionaries)
)]
)]
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/Properties/Settings.settings
View file @
7840a4b9
<?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)"
/>
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/SessionListItem.cs
View file @
7840a4b9
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
))
{
{
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
View file @
7840a4b9
<?
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
Tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
View file @
7840a4b9
...
@@ -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,8 +68,10 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -68,8 +68,10 @@ 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
()
...
@@ -96,7 +98,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -96,7 +98,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
}
}
/// <summary>
/// <summary>
/// Allows overriding default certificate validation logic
///
Allows overriding default certificate validation logic
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
@@ -112,7 +114,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -112,7 +114,7 @@ namespace Titanium.Web.Proxy.IntegrationTests
}
}
/// <summary>
/// <summary>
/// Allows overriding default client certificate selection logic during mutual authentication
///
Allows overriding default client certificate selection logic during mutual authentication
/// </summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="e"></param>
...
...
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
7840a4b9
...
@@ -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
);
...
...
Tests/Titanium.Web.Proxy.UnitTests/ProxyServerTests.cs
View file @
7840a4b9
...
@@ -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
();
...
...
Tests/Titanium.Web.Proxy.UnitTests/SystemProxyTest.cs
View file @
7840a4b9
...
@@ -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
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment