Merge pull request #484 from roji/transactions_pspe
[mono.git] / mcs / class / System.Configuration / Test / dumper / dumper.cs
1 /* 
2 ** 1. compile using:
3 **    gmcs dumper.cs -r:System.dll -r:System.Web.dll -r:System.Web.Services.dll -r:System.Configuration.dll
4 ** 
5 ** 2. run it on windows:
6 **    > dumper.exe > dumper.out.microsoft
7 ** 
8 ** 3. transfer that file to linux and do:
9 **    $ dos2unix dumper.out.microsoft && sort dumper.out.microsoft > foo && mv foo dumper.out.microsoft
10 ** 
11 ** 4. run dumper on linux:
12 **    $ mono dumper.exe > dumper.out.linux && sort dumper.out.linux > foo && mv foo dumper.out.linux
13 ** 
14 ** 5. diff the results:
15 **    $ diff -u dumper.out.linux dumper.out.microsoft | grep ^[-+]
16 */
17
18 using System;
19
20 using System.Collections;
21 using System.Configuration;
22 using System.Net;
23 using System.Reflection;
24 using System.Web.Configuration;
25 using System.Web.Services.Configuration;
26
27 public class Dumper {
28         object[] things = {
29                 new AnonymousIdentificationSection (),
30                 new AssemblyCollection (),
31                 new AssemblyInfo ("foo"),
32                 new AuthenticationSection (),
33                 new AuthorizationRuleCollection (),
34                 new AuthorizationRule (AuthorizationRuleAction.Allow),
35                 new AuthorizationSection (),
36                 new BufferModesCollection (),
37                 new BufferModeSettings ("name", 10, 10, 10, TimeSpan.FromMinutes (1), TimeSpan.FromMinutes(1), 10),
38                 new BuildProviderCollection (),
39                 new BuildProvider (".cs", "CSharpProvider"),
40                 new CacheSection (),
41                 new ClientTargetCollection (),
42                 new ClientTarget ("alias", "userAgent"),
43                 new ClientTargetSection (),
44                 new CodeSubDirectoriesCollection (),
45                 new CodeSubDirectory ("dirname"),
46                 new CompilationSection (),
47                 new CompilerCollection (),
48                 new Compiler ("options", "ext", "lang", "type", 1),
49                 new CustomErrorCollection (),
50                 new CustomError (404, "redirect"),
51                 new CustomErrorsSection (),
52                 new DeploymentSection (),
53                 new EventMappingSettingsCollection (),
54                 new EventMappingSettings ("name", "type"),
55                 new ExpressionBuilderCollection (),
56                 new ExpressionBuilder ("prefix", "type"),
57                 new FormsAuthenticationConfiguration (),
58                 new FormsAuthenticationCredentials (),
59                 new FormsAuthenticationUserCollection (),
60                 new FormsAuthenticationUser ("name", "password"),
61                 new GlobalizationSection (),
62                 new HealthMonitoringSection (),
63                 new HostingEnvironmentSection (),
64                 new HttpCookiesSection (),
65                 new HttpHandlerActionCollection (),
66                 new HttpHandlerAction ("path", "type", "verb"),
67                 new HttpHandlersSection (),
68                 new HttpModuleActionCollection (),
69                 new HttpModuleAction ("name", "type"),
70                 new HttpModulesSection (),
71                 new HttpRuntimeSection (),
72                 new IdentitySection (),
73                 new MachineKeySection (),
74                 new MembershipSection (),
75                 new NamespaceCollection (),
76                 new NamespaceInfo ("name"),
77                 new OutputCacheProfileCollection (),
78                 new OutputCacheProfile ("name"),
79                 new OutputCacheSection (),
80                 new OutputCacheSettingsSection (),
81                 new PagesSection (),
82                 new PassportAuthentication (),
83                 new ProcessModelSection (),
84                 new ProfileGroupSettingsCollection (),
85                 new ProfileGroupSettings ("name"),
86                 new ProfilePropertySettingsCollection (),
87                 new ProfilePropertySettings ("name"),
88                 new ProfileSettingsCollection (),
89                 new ProfileSettings ("name"),
90                 new RoleManagerSection (),
91                 new RootProfilePropertySettingsCollection (),
92                 new RuleSettingsCollection (),
93                 new RuleSettings ("name", "event", "provider", "profile", 1, 1, TimeSpan.FromMinutes (5), "custom"),
94                 new SecurityPolicySection (),
95                 new SessionPageStateSection (),
96                 new SessionStateSection (),
97                 new SqlCacheDependencyDatabaseCollection (),
98                 new SqlCacheDependencyDatabase ("name", "connectionStringName"),
99                 new SqlCacheDependencySection (),
100                 new TagMapCollection (),
101                 new TagMapInfo ("tagType", "mappedTag"),
102                 new TagPrefixCollection (),
103                 new TagPrefixInfo ("tagPrefix", "nameSpace", "assembly", "tagName", "source"),
104                 new TraceSection (),
105                 new TransformerInfoCollection (),
106                 new TransformerInfo ("name", "type"),
107                 new TrustLevelCollection (),
108                 new TrustLevel ("name", "policyFile"),
109                 new TrustSection (),
110                 new UrlMappingCollection (),
111                 new UrlMapping ("~/url", "~/mappedUrl"), /* UrlMapping uses a callback validator to validate the url(s) */
112                 new UrlMappingsSection (),
113                 new VirtualDirectoryMappingCollection (),
114                 //              new VirtualDirectoryMapping ("\\phys\\dir", true),  /* PhysicalDirectory seems to validate its input without using a Validator (decorator, anyway..)*/
115                 new WebControlsSection (),
116                 new WebPartsPersonalizationAuthorization (),
117                 new WebPartsPersonalization (),
118                 new WebPartsSection (),
119                 new XhtmlConformanceSection (),
120
121                 /* System.Configuration stuff */
122                 new AppSettingsSection (),
123                 new IgnoreSection (),
124                 new ConnectionStringSettings (),
125                 new ConnectionStringSettingsCollection (),
126                 new ProtectedProviderSettings (),
127
128                 /* System.Web.Services stuff */
129                 new DiagnosticsElement (),
130                 new ProtocolElementCollection (),
131                 new ProtocolElement (),
132                 new SoapEnvelopeProcessingElement (),
133                 new SoapExtensionTypeElementCollection (),
134                 new SoapExtensionTypeElement (),
135                 new TypeElementCollection (),
136                 new TypeElement (),
137                 new WebServicesSection (),
138                 new WsdlHelpGeneratorElement (),
139                 new WsiProfilesElementCollection (),
140                 new WsiProfilesElement (),
141
142                 /* System.Net stuff */
143                 //new AuthenticationModuleElement (),
144                 //new AuthenticationModuleElementCollection (),
145                 //new AuthenticationModulesSection (),
146                 //new BypassElement (),
147                 //new BypassElementCollection (),
148                 //new ConnectionManagementElement (),
149                 //new ConnectionManagementElementCollection (),
150                 //new ConnectionManagementSection (),
151                 //new DefaultProxySection (),
152                 //new HttpCachePolicyElement (),
153                 //new Ipv6Element (),
154                 //new ModuleElement (),
155                 //new ModuleElementCollection (),
156         };
157
158         public Dumper ()
159         {
160         }
161
162         public void DumpProperties ()
163         {
164                 foreach (object o in things) {
165                         Type type = o.GetType ();
166                         PropertyInfo pinfo = type.GetProperty ("Properties", BindingFlags.Instance | BindingFlags.NonPublic);
167
168                         if (pinfo == null)
169                                 continue;
170
171                         ConfigurationPropertyCollection col = (ConfigurationPropertyCollection)pinfo.GetValue (o, null);
172                         foreach (ConfigurationProperty p in col) {
173                                 Console.WriteLine ("{0}.{1} (Type) = {2}", type, p.Name, p.Type);
174                                 if (p.Validator != null && p.Validator.GetType () != typeof (DefaultValidator))
175                                         Console.WriteLine ("{0}.{1} (Validator) = {2} ", type, p.Name, p.Validator);
176                         }
177                 }
178         }
179
180         public void DumpConverters ()
181         {
182                 foreach (object o in things) {
183                         Type type = o.GetType ();
184                         PropertyInfo pinfo = type.GetProperty ("Properties", BindingFlags.Instance | BindingFlags.NonPublic);
185
186                         if (pinfo == null)
187                                 continue;
188
189                         ConfigurationPropertyCollection col = (ConfigurationPropertyCollection)pinfo.GetValue (o, null);
190                         foreach (ConfigurationProperty p in col) {
191                                 if (p.Converter != null)
192                                         Console.WriteLine ("{0}.{1} (Converter) = {2} ", type, p.Name, p.Converter);
193                         }
194                 }
195         }
196
197         public void DumpElementProperties ()
198         {
199                 foreach (object o in things) {
200                         Type type = o.GetType ();
201                         PropertyInfo pinfo = type.GetProperty ("ElementProperty", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
202
203                         if (pinfo == null)
204                                 continue;
205
206                         ConfigurationElementProperty p = (ConfigurationElementProperty)pinfo.GetValue (o, null);
207                         if (p == null)
208                                 Console.WriteLine ("{0}.ElementProperty = null", type);
209                         else if (p.Validator == null)
210                                 Console.WriteLine ("{0}.ElementProperty (Validator) = null", type);
211                         else
212                                 Console.WriteLine ("{0}.ElementProperty (Validator) = {1} ({2})", type, p.Validator, p.Validator.CanValidate (type));
213                 }
214         }
215
216         public void DumpRuntimeObjects ()
217         {
218                 foreach (object o in things) {
219                         Type type = o.GetType ();
220                         MethodInfo minfo = type.GetMethod ("GetRuntimeObject", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
221
222                         if (minfo == null)
223                                 continue;
224
225                         object ro = minfo.Invoke (o, null);
226
227                         if (ro == null)
228                                 Console.WriteLine ("{0}.GetRuntimeObject() = null", type);
229                         else
230                                 Console.WriteLine ("{0}.GetRuntimeObject() = {1} ({2})", type, ro.GetType(), ro == o);
231                         if (ro.GetType() == typeof (Hashtable)) {
232                                 foreach (object key in ((Hashtable)ro).Keys)
233                                         Console.WriteLine (" hash[{0}] = {1}", key, ((Hashtable)ro)[key]);
234                         }
235                 }
236         }
237
238         public static void Main (string[] args) {
239                 Dumper d = new Dumper ();
240
241                 try {
242                         d.DumpProperties ();
243                         d.DumpConverters ();
244                         d.DumpElementProperties ();
245                         d.DumpRuntimeObjects ();
246                 }
247                 catch (Exception e) {
248                         Console.WriteLine (e);
249                 }
250         }
251
252 }