Skip to content

Commit 381d67e

Browse files
committed
Restore docs
1 parent 37e417a commit 381d67e

File tree

14,322 files changed

+777050
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

14,322 files changed

+777050
-0
lines changed

.merge_file_a03012

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using namespace System;
2+
3+
namespace DesignLibrary
4+
{
5+
public ref class ParentType
6+
{
7+
public:
8+
ref class NestedType
9+
{
10+
public:
11+
NestedType()
12+
{
13+
}
14+
};
15+
16+
ParentType()
17+
{
18+
NestedType^ nt = gcnew NestedType();
19+
}
20+
};
21+
}

.merge_file_a04788

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using namespace System;
2+
3+
namespace DesignLibrary
4+
{
5+
public ref class DayOfWeek03
6+
{
7+
array<String^, 2>^ dayOfWeek;
8+
9+
public:
10+
property String^ default[int, int]
11+
{
12+
String^ get(int month, int day)
13+
{
14+
return dayOfWeek[month - 1, day - 1];
15+
}
16+
}
17+
18+
DayOfWeek03()
19+
{
20+
dayOfWeek = gcnew array<String^, 2>(12, 7);
21+
dayOfWeek[0,0] = "Wed";
22+
dayOfWeek[0,1] = "Thu";
23+
// ...
24+
dayOfWeek[1,0] = "Sat";
25+
dayOfWeek[1,1] = "Sun";
26+
// ...
27+
}
28+
};
29+
30+
public ref class RedesignedDayOfWeek03
31+
{
32+
static array<String^>^ dayOfWeek =
33+
{"Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Mon"};
34+
35+
static array<int>^ daysInPreviousMonth =
36+
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
37+
38+
public:
39+
String^ GetDayOfWeek(int month, int day)
40+
{
41+
return dayOfWeek[(daysInPreviousMonth[month - 1] + day) % 7];
42+
}
43+
};
44+
}

.merge_file_a05724

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using namespace System;
2+
3+
[assembly: System::Runtime::InteropServices::ComVisible(false)];
4+
namespace DesignLibrary {}

.merge_file_a07512

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using namespace System;
2+
using namespace System::IO;
3+
4+
namespace DesignLibrary
5+
{
6+
// Creates two violations of the rule.
7+
public ref class GenericExceptionsCaught
8+
{
9+
FileStream^ inStream;
10+
FileStream^ outStream;
11+
12+
public:
13+
GenericExceptionsCaught(String^ inFile, String^ outFile)
14+
{
15+
try
16+
{
17+
inStream = File::Open(inFile, FileMode::Open);
18+
}
19+
catch(SystemException^ e)
20+
{
21+
Console::WriteLine("Unable to open {0}.", inFile);
22+
}
23+
24+
try
25+
{
26+
outStream = File::Open(outFile, FileMode::Open);
27+
}
28+
catch(Exception^ e)
29+
{
30+
Console::WriteLine("Unable to open {0}.", outFile);
31+
}
32+
}
33+
};
34+
35+
public ref class GenericExceptionsCaughtFixed
36+
{
37+
FileStream^ inStream;
38+
FileStream^ outStream;
39+
40+
public:
41+
GenericExceptionsCaughtFixed(String^ inFile, String^ outFile)
42+
{
43+
try
44+
{
45+
inStream = File::Open(inFile, FileMode::Open);
46+
}
47+
48+
// Fix the first violation by catching a specific exception.
49+
catch(FileNotFoundException^ e)
50+
{
51+
Console::WriteLine("Unable to open {0}.", inFile);
52+
}
53+
54+
try
55+
{
56+
outStream = File::Open(outFile, FileMode::Open);
57+
}
58+
59+
// Fix the second violation by re-throwing the generic
60+
// exception at the end of the catch block.
61+
catch(Exception^ e)
62+
{
63+
Console::WriteLine("Unable to open {0}.", outFile);
64+
throw;
65+
}
66+
}
67+
};
68+
}

.merge_file_a09104

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using namespace System;
2+
3+
[assembly:CLSCompliant(true)];
4+
namespace DesignLibrary {}

.merge_file_a09864

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using namespace System;
2+
3+
namespace DesignLibrary
4+
{
5+
public ref class AlarmEventArgs : public EventArgs {};
6+
public delegate void AlarmEventHandler(
7+
Object^ sender, AlarmEventArgs^ e);
8+
}

.merge_file_a10940

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using namespace System;
2+
using namespace System::Reflection;
3+
4+
[assembly: AssemblyVersionAttribute("4.3.2.1")];
5+
namespace DesignLibrary {}

.merge_file_a11748

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using namespace System;
2+
using namespace System::IO;
3+
4+
namespace DesignLibrary
5+
{
6+
public ref class StreamUser
7+
{
8+
int anInteger;
9+
10+
public:
11+
void ManipulateFileStream(FileStream^ stream)
12+
{
13+
while((anInteger = stream->ReadByte()) != -1)
14+
{
15+
// Do something.
16+
}
17+
}
18+
19+
void ManipulateAnyStream(Stream^ anyStream)
20+
{
21+
while((anInteger = anyStream->ReadByte()) != -1)
22+
{
23+
// Do something.
24+
}
25+
}
26+
};
27+
}
28+
29+
using namespace DesignLibrary;
30+
31+
static void main()
32+
{
33+
StreamUser^ someStreamUser = gcnew StreamUser();
34+
FileStream^ testFileStream =
35+
gcnew FileStream("test.dat", FileMode::OpenOrCreate);
36+
MemoryStream^ testMemoryStream =
37+
gcnew MemoryStream(gcnew array<Byte>{});
38+
39+
// Cannot be used with testMemoryStream.
40+
someStreamUser->ManipulateFileStream(testFileStream);
41+
42+
someStreamUser->ManipulateAnyStream(testFileStream);
43+
someStreamUser->ManipulateAnyStream(testMemoryStream);
44+
45+
testFileStream->Close();
46+
}

.merge_file_a13284

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using namespace System;
2+
3+
namespace DesignLibrary
4+
{
5+
public enum class TraceLevel
6+
{
7+
Off = 0,
8+
Error = 1,
9+
Warning = 2,
10+
Info = 3,
11+
Verbose = 4
12+
};
13+
14+
[Flags]
15+
public enum class TraceOptions
16+
{
17+
None = 0,
18+
CallStack = 0x01,
19+
LogicalStack = 0x02,
20+
DateTime = 0x04,
21+
Timestamp = 0x08
22+
};
23+
24+
[Flags]
25+
public enum class BadTraceOptions
26+
{
27+
CallStack = 0,
28+
LogicalStack = 0x01,
29+
DateTime = 0x02,
30+
Timestamp = 0x04
31+
};
32+
}
33+
34+
using namespace DesignLibrary;
35+
36+
void main()
37+
{
38+
// Set the flags.
39+
BadTraceOptions badOptions = safe_cast<BadTraceOptions>
40+
(BadTraceOptions::LogicalStack | BadTraceOptions::Timestamp);
41+
42+
// Check whether CallStack is set.
43+
if((badOptions & BadTraceOptions::CallStack) ==
44+
BadTraceOptions::CallStack)
45+
{
46+
// This 'if' statement is always true.
47+
}
48+
}

0 commit comments

Comments
 (0)