CompilerResults Klasa
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Reprezentuje wyniki kompilacji, które są zwracane z kompilatora.
public ref class CompilerResults
public class CompilerResults
[System.Serializable]
public class CompilerResults
type CompilerResults = class
[<System.Serializable>]
type CompilerResults = class
Public Class CompilerResults
- Dziedziczenie
-
CompilerResults
- Pochodne
- Atrybuty
Przykłady
// Displays information from a CompilerResults.
[PermissionSet(SecurityAction::Demand, Name="FullTrust")]
static void DisplayCompilerResults( System::CodeDom::Compiler::CompilerResults^ cr )
{
// If errors occurred during compilation, output the compiler output and errors.
if ( cr->Errors->Count > 0 )
{
for ( int i = 0; i < cr->Output->Count; i++ )
Console::WriteLine( cr->Output[ i ] );
for ( int i = 0; i < cr->Errors->Count; i++ )
Console::WriteLine( String::Concat( i, ": ", cr->Errors[ i ] ) );
}
else
{
// Display information ab->Item[Out] the* compiler's exit code and the generated assembly.
Console::WriteLine( "Compiler returned with result code: {0}", cr->NativeCompilerReturnValue );
Console::WriteLine( "Generated assembly name: {0}", cr->CompiledAssembly->FullName );
if ( cr->PathToAssembly == nullptr )
Console::WriteLine( "The assembly has been generated in memory." );
else
Console::WriteLine( "Path to assembly: {0}", cr->PathToAssembly );
// Display temporary files information.
if ( !cr->TempFiles->KeepFiles )
Console::WriteLine( "Temporary build files were deleted." );
else
{
Console::WriteLine( "Temporary build files were not deleted." );
// Display a list of the temporary build files
IEnumerator^ enu = cr->TempFiles->GetEnumerator();
for ( int i = 0; enu->MoveNext(); i++ )
Console::WriteLine("TempFile " + i.ToString() + ": " + (String^)(enu->Current) );
}
}
}
// Displays information from a CompilerResults.
public static void DisplayCompilerResults(System.CodeDom.Compiler.CompilerResults cr)
{
// If errors occurred during compilation, output the compiler output and errors.
if( cr.Errors.Count > 0 )
{
for( int i=0; i<cr.Output.Count; i++ )
Console.WriteLine( cr.Output[i] );
for( int i=0; i<cr.Errors.Count; i++ )
Console.WriteLine( i.ToString() + ": " + cr.Errors[i].ToString() );
}
else
{
// Display information about the compiler's exit code and the generated assembly.
Console.WriteLine( "Compiler returned with result code: " + cr.NativeCompilerReturnValue.ToString() );
Console.WriteLine( "Generated assembly name: " + cr.CompiledAssembly.FullName );
if( cr.PathToAssembly == null )
Console.WriteLine( "The assembly has been generated in memory." );
else
Console.WriteLine( "Path to assembly: " + cr.PathToAssembly );
// Display temporary files information.
if( !cr.TempFiles.KeepFiles )
{
Console.WriteLine( "Temporary build files were deleted." );
}
else
{
Console.WriteLine( "Temporary build files were not deleted." );
// Display a list of the temporary build files
IEnumerator enu = cr.TempFiles.GetEnumerator();
for( int i=0; enu.MoveNext(); i++ )
Console.WriteLine( "TempFile " + i.ToString() + ": " + (string)enu.Current );
}
}
}
' Displays information from a CompilerResults.
Public Shared Sub DisplayCompilerResults(ByVal cr As System.CodeDom.Compiler.CompilerResults)
' If errors occurred during compilation, output the compiler output and errors.
If cr.Errors.Count > 0 Then
Dim i As Integer
For i = 0 To cr.Output.Count - 1
Console.WriteLine(cr.Output(i))
Next i
For i = 0 To cr.Errors.Count - 1
Console.WriteLine((i.ToString() + ": " + cr.Errors(i).ToString()))
Next i
Else
' Display information about the compiler's exit code and the generated assembly.
Console.WriteLine(("Compiler returned with result code: " + cr.NativeCompilerReturnValue.ToString()))
Console.WriteLine(("Generated assembly name: " + cr.CompiledAssembly.FullName))
If cr.PathToAssembly Is Nothing Then
Console.WriteLine("The assembly has been generated in memory.")
Else
Console.WriteLine(("Path to assembly: " + cr.PathToAssembly))
End If
' Display temporary files information.
If Not cr.TempFiles.KeepFiles Then
Console.WriteLine("Temporary build files were deleted.")
Else
Console.WriteLine("Temporary build files were not deleted.")
' Display a list of the temporary build files
Dim enu As IEnumerator = cr.TempFiles.GetEnumerator()
Dim i As Integer
i = 0
While enu.MoveNext()
Console.WriteLine(("TempFile " + i.ToString() + ": " + CStr(enu.Current)))
i += 1
End While
End If
End If
End Sub
Uwagi
Ta klasa zawiera następujące informacje o wynikach kompilacji przez implementację interfejsu ICodeCompiler :
Właściwość CompiledAssembly wskazuje skompilowany zestaw.
Właściwość Evidence wskazuje dowody zabezpieczeń dla zestawu.
Właściwość PathToAssembly wskazuje ścieżkę do skompilowanego zestawu, jeśli nie został wygenerowany tylko w pamięci.
Właściwość Errors wskazuje wszelkie błędy i ostrzeżenia kompilatora.
Właściwość Output zawiera komunikaty wyjściowe kompilatora.
Właściwość NativeCompilerReturnValue wskazuje wartość kodu wyniku zwróconą przez kompilator.
Właściwość TempFiles wskazuje pliki tymczasowe wygenerowane podczas kompilacji i łączenia.
Uwaga
Ta klasa zawiera żądanie dziedziczenia na poziomie klasy, które ma zastosowanie do wszystkich składowych. Element SecurityException jest zgłaszany, gdy klasa pochodna nie ma uprawnienia pełnego zaufania. Aby uzyskać szczegółowe informacje o żądaniach dziedziczenia, zobacz Żądania dziedziczenia.
Konstruktory
CompilerResults(TempFileCollection) |
Inicjuje CompilerResults nowe wystąpienie klasy, które używa określonych plików tymczasowych. |
Właściwości
CompiledAssembly |
Pobiera lub ustawia skompilowany zestaw. |
Errors |
Pobiera kolekcję błędów i ostrzeżeń kompilatora. |
Evidence |
Przestarzałe.
Wskazuje obiekt dowodów reprezentujący uprawnienia zasad zabezpieczeń skompilowanego zestawu. |
NativeCompilerReturnValue |
Pobiera lub ustawia wartość zwracaną kompilatora. |
Output |
Pobiera komunikaty wyjściowe kompilatora. |
PathToAssembly |
Pobiera lub ustawia ścieżkę skompilowanego zestawu. |
TempFiles |
Pobiera lub ustawia tymczasową kolekcję plików do użycia. |
Metody
Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt. (Odziedziczone po Object) |
GetHashCode() |
Służy jako domyślna funkcja skrótu. (Odziedziczone po Object) |
GetType() |
Type Pobiera wartość bieżącego wystąpienia. (Odziedziczone po Object) |
MemberwiseClone() |
Tworzy płytkią kopię bieżącego Objectelementu . (Odziedziczone po Object) |
ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Odziedziczone po Object) |
Dotyczy
Zobacz też
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla