Skip to content
Merged
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

void ValidateBtn_Click(Object sender, EventArgs e) {

if (Page.IsValid == true) {
if (Page.IsValid) {
lblOutput.Text = "Required field is filled!";
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//<Snippet4>

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/polling.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
#using <TestMethod.dll>

using namespace System;
Expand All @@ -21,7 +21,7 @@
threadId, nullptr, nullptr);

// Poll while simulating work.
while(result->IsCompleted == false)
while(!result->IsCompleted)
{
Thread::Sleep(250);
Console::Write(".");
Expand Down
2 changes: 1 addition & 1 deletion snippets/cpp/VS_Snippets_CLR/T.TryParse/CPP/tp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//<snippet1>

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR/T.TryParse/CPP/tp.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
// This example demonstrates overloads of the TryParse method for
// several base types, and the TryParseExact method for DateTime.
// In most cases, this example uses the most complex overload; that is, the overload
Expand All @@ -16,7 +16,7 @@
String^ msgFailure = L"** Parse for {0} failed. Invalid input.";

//
if ( parseResult == true )
if ( parseResult )
Console::WriteLine( msgSuccess, typeName, parseValue );
else
Console::WriteLine( msgFailure, typeName );
Expand Down
2 changes: 1 addition & 1 deletion snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
//<snippet1>
// This example demonstrates the Console.Beep() method.
using namespace System;
Expand All @@ -8,7 +8,7 @@
int x = 0;

//
if ( (args->Length == 2) && (Int32::TryParse( args[ 1 ], x ) == true) && ((x >= 1) && (x <= 9)) )
if ( (args->Length == 2) && (Int32::TryParse( args[ 1 ], x )) && ((x >= 1) && (x <= 9)) )
{
for ( int i = 1; i <= x; i++ )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//<snippet1>

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR/console.cursorvis/CPP/vis.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
// This example demonstrates the Console.CursorVisible property.
using namespace System;

Expand All @@ -21,7 +21,7 @@
{
Console::WriteLine( m1, ((Console::CursorVisible == true) ? (String^)"VISIBLE" : "HIDDEN") );
s = Console::ReadLine();
if ( String::IsNullOrEmpty( s ) == false )
if ( !String::IsNullOrEmpty( s ) )
if ( s[ 0 ] == '+' )
Console::CursorVisible = true;
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR/console.keyavailable/CPP/ka.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
//<snippet1>
using namespace System;
using namespace System::Threading;
Expand All @@ -11,7 +11,7 @@

// Your code could perform some useful task in the following loop. However,
// for the sake of this example we'll merely pause for a quarter second.
while ( Console::KeyAvailable == false )
while ( !Console::KeyAvailable )
Thread::Sleep( 250 );
cki = Console::ReadKey( true );
Console::WriteLine( "You pressed the '{0}' key.", cki.Key );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
// <snippet1>
using namespace System;
using namespace System::IO;
Expand All @@ -9,7 +9,7 @@
DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" );

// Create the directory only if it does not already exist.
if ( di->Exists == false )
if ( !di->Exists )
di->Create();


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR_System/system.GC.ReRegisterForFinalize Example/CPP/class1.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
//<snippet1>
using namespace System;
ref class MyFinalizeObject
Expand All @@ -17,7 +17,7 @@

~MyFinalizeObject()
{
if ( hasFinalized == false )
if ( !hasFinalized )
{
Console::WriteLine( "First finalization" );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <Snippet5>

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
using namespace System;

void main()
Expand All @@ -8,7 +8,7 @@
unsigned int numbers = 0;
Random^ rnd = gcnew Random();

if (! UInt32::TryParse(line, numbers))
if (!UInt32::TryParse(line, numbers))
numbers = 10;

for (unsigned int ctr = 1; ctr <= numbers; ctr++)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// FormatExample2.cpp : Defines the entry point for the console application.

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample2.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
//

// #include "stdafx.h"
Expand All @@ -21,7 +21,7 @@
Object^ arg,
IFormatProvider^ formatProvider)
{
if (! this->Equals(formatProvider))
if (!this->Equals(formatProvider))
{
return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using namespace System;

Check failure on line 1 in snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.

ref class FileUtilities
{
public:
static String^ AppendDirectorySeparator(String^ dir)
{
if (! dir->Trim()->EndsWith(System::IO::Path::DirectorySeparatorChar.ToString()))
if (!dir->Trim()->EndsWith(System::IO::Path::DirectorySeparatorChar.ToString()))
return dir->Trim() + System::IO::Path::DirectorySeparatorChar;
else
return dir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public ref class MyTcpClientExample
tcpClient->NoDelay = true;

// Determines if the delay is enabled by using the NoDelay property.
if ( tcpClient->NoDelay == true )
if ( tcpClient->NoDelay)
Console::WriteLine( "The delay was set successfully to {0}", tcpClient->NoDelay );


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main()
// <Snippet3>
// <Snippet4>
// Check whether the given XmlTextReader is readable.
if ( DiscoveryDocument::CanRead( myXmlTextReader ) == true )
if ( DiscoveryDocument::CanRead( myXmlTextReader ) )

// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main()

// <Snippet2>
DiscoveryExceptionDictionary^ myExceptionDictionary = myDiscoveryClientProtocol2->Errors;
if ( myExceptionDictionary->Contains( myUrlKey ) == true )
if ( myExceptionDictionary->Contains( myUrlKey ))
{
Console::WriteLine( "'myExceptionDictionary' contains a discovery exception for the key '{0}'", myUrlKey );
}
Expand All @@ -57,7 +57,7 @@ int main()
Console::WriteLine( "'myExceptionDictionary' does not contain a discovery exception for the key '{0}'", myUrlKey );
}
// </Snippet2>
if ( myExceptionDictionary->Contains( myUrlKey ) == true )
if ( myExceptionDictionary->Contains( myUrlKey ) )
{
Console::WriteLine( "System generated exceptions." );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main()
Console::WriteLine( "The number of elements in the collection after adding two elements to the collection: {0}", myDiscoveryReferenceCollection->Count );

// Call the Contains method.
if ( myDiscoveryReferenceCollection->Contains( myDiscoveryDocReference1 ) != true )
if ( !myDiscoveryReferenceCollection->Contains( myDiscoveryDocReference1 ) )
{
throw gcnew Exception( "Element not found in collection." );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ref class MyCustomChannel: public IChannelReceiver
// Start listening to the port.
virtual void StartListening( Object^ data )
{
if ( myListening == false )
if ( !myListening )
{
myTcpListener->Start();
myListening = true;
Expand All @@ -128,7 +128,7 @@ ref class MyCustomChannel: public IChannelReceiver
// Stop listening to the port.
virtual void StopListening( Object^ data )
{
if ( myListening == true )
if ( myListening )
{
myTcpListener->Stop();
myListening = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ref class MyNewQueue
// This exception would be thrown if there is no (further) acknowledgment message
// with the specified correlation Id. Only output a message if there are no messages;
// not if the loop has found at least one.
if ( found == false )
if ( !found )
{
Console::WriteLine( e->Message );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ref class MyNewQueue
MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" );

// Send a message to the queue.
if ( myQueue->Transactional == true )
if ( myQueue->Transactional)
{
// Create a transaction.
MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ref class MyNewQueue
MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" );

// Send a message to the queue.
if ( myQueue->Transactional == true )
if ( myQueue->Transactional )
{
// Create a transaction.
MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ref class MyNewQueue
MessageQueue^ myQueue = gcnew MessageQueue( ".\\myTransactionalQueue" );

// Send a message to the queue.
if ( myQueue->Transactional == true )
if ( myQueue->Transactional )
{
// Create a transaction.
MessageQueueTransaction^ myTransaction = gcnew MessageQueueTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ref class MyNewQueue
MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

// Send a message to the queue.
if ( myQueue->Transactional == true )
if ( myQueue->Transactional )
{

// Create a transaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ref class SelectedHostsCredentialPolicy: public ICredentialPolicy
virtual bool ShouldSendCredential( Uri^ challengeUri, WebRequest^ request, NetworkCredential^ /*credential*/, IAuthenticationModule^ /*authModule*/ )
{
Console::WriteLine( L"Checking custom credential policy." );
if ( request->RequestUri->Host->Equals( L"www.contoso.com" ) || challengeUri->IsLoopback == true )
if ( request->RequestUri->Host->Equals( L"www.contoso.com" ) || challengeUri->IsLoopback )
return true;

return false;
Expand All @@ -41,7 +41,7 @@ public ref class HttpsBasicCredentialPolicy: public IntranetZoneCredentialPolicy
{
Console::WriteLine( L"Checking custom credential policy for HTTPS and basic." );
bool answer = IntranetZoneCredentialPolicy::ShouldSendCredential( challengeUri, request, credential, authModule );
if ( answer == true )
if ( answer )
{
Console::WriteLine( L"Sending credential for intranet resource." );
return answer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public ref class FtpRequestTest
// Example: ftp://contoso.com/someFile.txt.
//
// The command parameter identifies the command to send to the server.
if ( serverUri->ToLower()->StartsWith( Uri::UriSchemeFtp ) == false )
if ( !serverUri->ToLower()->StartsWith( Uri::UriSchemeFtp ) )
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ void DisplayIPv4NetworkInterfaces()
NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum23->Current);

// Only display informatin for interfaces that support IPv4.
if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) == false )
if ( !adapter->Supports( NetworkInterfaceComponent::IPv4 ) )
{
continue;
}
Expand Down Expand Up @@ -875,7 +875,7 @@ void DisplayIPv6NetworkInterfaces()
NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum24->Current);

// Only display informatin for interfaces that support IPv6.
if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) == false )
if ( !adapter->Supports( NetworkInterfaceComponent::IPv6 ) )
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void SampleTryCreate()

// Parse the string and create a new Uri instance, if possible.
Uri^ result;
if ( Uri::TryCreate( addressString, UriKind::RelativeOrAbsolute, result ) == true )
if ( Uri::TryCreate( addressString, UriKind::RelativeOrAbsolute, result ) )
{
// The call was successful. Write the URI address to the console.
Console::Write( result );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace Example

//<snippet1>
char testChar = 'e';
if ( Uri::IsHexDigit( testChar ) == true )
if ( Uri::IsHexDigit( testChar ) )
{
Console::WriteLine( "'{0}' is the hexadecimal representation of {1}",
testChar, Uri::FromHex( testChar ) );
Expand Down Expand Up @@ -236,7 +236,7 @@ namespace Example

#if OLDMETHOD
Uri^ result;
if ( Uri::TryParse( uriString, false, false, result ) == true )
if ( Uri::TryParse( uriString, false, false, result ) )
{
Console::WriteLine( "{0} is a valid Uri", result );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main(array<String^>^ args)
String^ answer = Console::ReadLine();
// If the user canceled the send, and mail hasn't been
// sent yet,then cancel the pending operation.
if (answer->ToLower()->StartsWith("c") && mailSent == false)
if (answer->ToLower()->StartsWith("c") && !mailSent)
{
client->SendAsyncCancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public ref class SslTcpClient
// while waiting for the asynchronous calls to complete.
System::Threading::Thread::Sleep( 100 );
}
while ( complete != true && Console::KeyAvailable == false );
while ( !complete && !Console::KeyAvailable );

if ( Console::KeyAvailable )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main()

// <Snippet3>
// <Snippet4>
if ( myOperationCollection->Contains( myOperation ) == true )
if ( myOperationCollection->Contains( myOperation ))
{
Console::WriteLine( "The index of the added 'myOperation' operation is : {0}", myOperationCollection->IndexOf( myOperation ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main()

// <Snippet5>
// <Snippet6>
if ( myOperationMessageCollection->Contains( myOperationMessage ) == true )
if ( myOperationMessageCollection->Contains( myOperationMessage ))
{
int myIndex = myOperationMessageCollection->IndexOf( myOperationMessage );
Console::WriteLine( " The index of the Add operation message in the collection is : {0}", myIndex );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void RunUdpTests()
Thread^ myThread1 = gcnew Thread( myThreadDelegate );
myThread1->Start();

while ( myThread1->IsAlive == true )
while ( myThread1->IsAlive )
{
NeedForDelegates::SendTo1();
}
Expand All @@ -354,7 +354,7 @@ void RunUdpTests()
Console::WriteLine( "UDP test2" );
Thread^ myThread2 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom2 ) );
myThread2->Start();
while ( myThread2->IsAlive == true )
while ( myThread2->IsAlive )
{
NeedForDelegates::SendTo2();
}
Expand All @@ -363,7 +363,7 @@ void RunUdpTests()
Console::WriteLine( "UDP test3" );
Thread^ myThread3 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom3 ) );
myThread3->Start();
while ( myThread3->IsAlive == true )
while ( myThread3->IsAlive )
{
NeedForDelegates::SendTo3();
}
Expand All @@ -372,7 +372,7 @@ void RunUdpTests()
Console::WriteLine( "UDP test4" );
Thread^ myThread4 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom4 ) );
myThread4->Start();
while ( myThread4->IsAlive == true )
while ( myThread4->IsAlive )
{
NeedForDelegates::SendTo4();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int main()
}

String^ proxy = args[ 1 ];
if ( (rex->Match(proxy))->Success != true )
if ( (!rex->Match(proxy))->Success)
{
Console::WriteLine( "Input string format not allowed." );
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ int main(array<String^>^ args)
}
String^ proxy = args[1];

if ((expression->Match(proxy))->Success != true)
if (!(expression->Match(proxy))->Success)
{
Console::WriteLine("Input string format not allowed.");
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ref class Form1: public Form
// Prints the type of each attribute in the collection.
Object^ myAttribute;
System::Text::StringBuilder^ text = gcnew System::Text::StringBuilder;
while ( ie->MoveNext() == true )
while ( ie->MoveNext() )
{
myAttribute = ie->Current;
text->Append( myAttribute );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ref class Form1: public System::Windows::Forms::Form
{
if ( !textBox1->Text->Equals( "" ) )
{
if ( checkedListBox1->CheckedItems->Contains( textBox1->Text ) == false )
if ( !checkedListBox1->CheckedItems->Contains( textBox1->Text ) )
checkedListBox1->Items->Add( textBox1->Text, CheckState::Checked );
textBox1->Text = "";
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public ref class Form1: public System::Windows::Forms::Form
IEnumerator^ myEnumerator;
myEnumerator = checkedListBox1->CheckedIndices->GetEnumerator();
int y;
while ( myEnumerator->MoveNext() != false )
while ( myEnumerator->MoveNext() )
{
y = safe_cast<Int32>(myEnumerator->Current);
checkedListBox1->SetItemChecked( y, false );
Expand Down
Loading