Browse Source

Fixed bug in ReflectionOnly assembly loading.

Fixed crash when a pad could not be loaded.
Added publisher policy.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@233 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
3c524117ba
  1. 4
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  2. 7
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
  3. 1
      src/Main/Base/Project/Src/Internal/Erbauer/PadDescriptor.cs
  4. 21
      src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs
  5. 4
      src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs
  6. 20
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs
  7. 10
      src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs
  8. 30
      src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs
  9. 3
      src/Main/StartUp/Project/Dialogs/ExceptionBox.cs
  10. 22
      src/Main/StartUp/Project/SharpDevelop.exe.config
  11. 18
      src/Main/StartUp/Project/SharpDevelopMain.cs
  12. 3
      src/Main/StartUp/Project/StartUp.csproj
  13. 56
      src/Tools/UpdateAssemblyInfo/Main.cs
  14. 1
      src/Tools/UpdateAssemblyInfo/Readme.txt
  15. 1
      src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj
  16. 6
      src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln

4
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -156,7 +156,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -156,7 +156,9 @@ namespace ICSharpCode.SharpDevelop.Gui
try {
ArrayList contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems(this);
foreach (PadDescriptor content in contents) {
ShowPad(content);
if (content != null) {
ShowPad(content);
}
}
} catch (TreePathNotFoundException) {}

7
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -338,10 +338,13 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -338,10 +338,13 @@ namespace ICSharpCode.SharpDevelop.Gui
public void ActivateContent()
{
if (!isInitialized) {
Control control = padDescriptor.PadContent.Control;
isInitialized = true;
IPadContent content = padDescriptor.PadContent;
if (content == null)
return;
Control control = content.Control;
control.Dock = DockStyle.Fill;
Controls.Add(control);
isInitialized = true;
}
}

1
src/Main/Base/Project/Src/Internal/Erbauer/PadDescriptor.cs

@ -104,6 +104,7 @@ namespace ICSharpCode.Core @@ -104,6 +104,7 @@ namespace ICSharpCode.Core
public void BringPadToFront()
{
CreatePad();
if (padContent == null) return;
if (!WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(this)) {
WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(this);
}

21
src/Main/Base/Project/Src/Services/ParserService/ProjectContentRegistry.cs

@ -173,17 +173,30 @@ namespace ICSharpCode.Core @@ -173,17 +173,30 @@ namespace ICSharpCode.Core
static Assembly AssemblyResolve(object sender, ResolveEventArgs e)
{
string shortName = e.Name;
Console.Write("AssemblyResolve: " + e.Name);
int pos = shortName.IndexOf(',');
if (pos > 0)
shortName = shortName.Substring(0, pos);
string path = Path.Combine(lookupDirectory, shortName);
if (File.Exists(path + ".dll"))
if (File.Exists(path + ".dll")) {
Console.WriteLine(" - found .dll file");
return Assembly.ReflectionOnlyLoadFrom(path + ".dll");
if (File.Exists(path + ".exe"))
}
if (File.Exists(path + ".exe")) {
Console.WriteLine(" - found .exe file");
return Assembly.ReflectionOnlyLoadFrom(path + ".exe");
if (File.Exists(path))
}
if (File.Exists(path)) {
Console.WriteLine(" - found file");
return Assembly.ReflectionOnlyLoadFrom(path);
return null;
}
try {
Console.WriteLine(" - try ReflectionOnlyLoad");
return Assembly.ReflectionOnlyLoad(e.Name);
} catch (FileNotFoundException ex) {
Console.WriteLine("AssemblyResolve: " + ex.Message);
return null;
}
}
public static Assembly LoadGACAssembly(string partialName, bool reflectionOnly)

4
src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs

@ -29,9 +29,7 @@ namespace ICSharpCode.Core @@ -29,9 +29,7 @@ namespace ICSharpCode.Core
ICompilationUnit assemblyCompilationUnit = new DefaultCompilationUnit(this);
foreach (Type type in assembly.GetExportedTypes()) {
//if (!type.FullName.StartsWith("<") && type.IsPublic) {
AddClassToNamespaceListInternal(new ReflectionClass(assemblyCompilationUnit, type, null));
//}
AddClassToNamespaceListInternal(new ReflectionClass(assemblyCompilationUnit, type, null));
}
if (assembly == typeof(void).Assembly) {

20
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -175,6 +175,26 @@ namespace ICSharpCode.SharpDevelop.Project @@ -175,6 +175,26 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
/// <summary>
/// Load a single project as solution.
/// </summary>
public static void LoadProject(string fileName)
{
openSolution = new Solution();
openSolution.Name = Path.GetFileNameWithoutExtension(fileName);
openSolution.Save(Path.ChangeExtension(fileName, ".sln"));
OnSolutionLoaded(new SolutionEventArgs(openSolution));
ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(fileName);
IProject newProject;
if (binding != null) {
newProject = binding.LoadProject(fileName, openSolution.Name);
} else {
newProject = new UnknownProject(fileName);
}
newProject.IdGuid = Guid.NewGuid().ToString();
openSolution.AddFolder(newProject);
}
public static void SaveSolution()
{
if (openSolution != null) {

10
src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs

@ -21,7 +21,9 @@ namespace ICSharpCode.Core @@ -21,7 +21,9 @@ namespace ICSharpCode.Core
List<Runtime> runtimes = new List<Runtime>();
string addInFileName = null;
Dictionary<string, ExtensionPath> paths = new Dictionary<string, ExtensionPath>();
static bool hasShownErrorMessage = false;
public object CreateObject(string className)
{
foreach (Runtime runtime in runtimes) {
@ -30,7 +32,11 @@ namespace ICSharpCode.Core @@ -30,7 +32,11 @@ namespace ICSharpCode.Core
return o;
}
}
MessageService.ShowError("Cannot create object: " + className);
Console.WriteLine("Cannot create object: " + className);
if (!hasShownErrorMessage) {
hasShownErrorMessage = true;
MessageService.ShowError("Cannot create object: " + className + "\nFuture missing objects will not cause an error message.");
}
return null;
}

30
src/Main/Core/Project/Src/AddInTree/AddIn/Runtime.cs

@ -32,17 +32,30 @@ namespace ICSharpCode.Core @@ -32,17 +32,30 @@ namespace ICSharpCode.Core
return assembly;
}
}
bool isAssemblyLoaded;
public Assembly LoadedAssembly {
get {
if (loadedAssembly == null) {
if (!isAssemblyLoaded) {
#if DEBUG
Console.WriteLine("Loading addin " + assembly + "...");
#endif
if (assembly[0] == '/') {
loadedAssembly = System.Reflection.Assembly.Load(assembly.Substring(1));
} else {
loadedAssembly = System.Reflection.Assembly.LoadFrom(Path.Combine(hintPath, assembly));
isAssemblyLoaded = true;
try {
if (assembly[0] == '/') {
loadedAssembly = System.Reflection.Assembly.Load(assembly.Substring(1));
} else {
loadedAssembly = System.Reflection.Assembly.LoadFrom(Path.Combine(hintPath, assembly));
}
loadedAssembly.GetExportedTypes(); // preload assembly to provoke FileLoadException if dependencies are missing
} catch (FileNotFoundException ex) {
MessageService.ShowError("The addin '" + assembly + "' could not be loaded:\n" + ex.ToString());
} catch (FileLoadException ex) {
MessageService.ShowError("The addin '" + assembly + "' could not be loaded:\n" + ex.ToString());
}
}
return loadedAssembly;
@ -63,7 +76,10 @@ namespace ICSharpCode.Core @@ -63,7 +76,10 @@ namespace ICSharpCode.Core
public object CreateInstance(string instance)
{
return LoadedAssembly.CreateInstance(instance);
Assembly asm = LoadedAssembly;
if (asm == null)
return null;
return asm.CreateInstance(instance);
}
internal static Runtime Read(AddIn addIn, XmlTextReader reader, string hintPath)

3
src/Main/StartUp/Project/Dialogs/ExceptionBox.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop @@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop
str += "Boot Mode : " + SystemInformation.BootMode + Environment.NewLine;
str += "Working Set Memory : " + (Environment.WorkingSet / 1024) + "kb" + Environment.NewLine;
Version v = Assembly.GetEntryAssembly().GetName().Version;
str += "SharpDevelop Version : " + v.Major + "." + v.Minor + "." + v.Revision + "." + v.Build + Environment.NewLine;
str += "SharpDevelop Version : " + v.Major + "." + v.Minor + "." + v.Build + "." + v.Revision + Environment.NewLine;
str += Environment.NewLine;
if (message != null) {
@ -103,6 +103,7 @@ namespace ICSharpCode.SharpDevelop @@ -103,6 +103,7 @@ namespace ICSharpCode.SharpDevelop
void continueButtonClick(object sender, System.EventArgs e)
{
DialogResult = System.Windows.Forms.DialogResult.Ignore;
Close();
}
void InitializeComponent() {

22
src/Main/StartUp/Project/SharpDevelop.exe.config

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.Core" publicKeyToken="f829da5c02be14ee" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.1" newVersion="2.0.0.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.SharpDevelop" publicKeyToken="f829da5c02be14ee" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.1" newVersion="2.0.0.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.TextEditor" publicKeyToken="4d61825e8dd49f1a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.1" newVersion="2.0.0.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory" publicKeyToken="efe927acf176eea2" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.1" newVersion="2.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

18
src/Main/StartUp/Project/SharpDevelopMain.cs

@ -91,7 +91,11 @@ namespace ICSharpCode.SharpDevelop @@ -91,7 +91,11 @@ namespace ICSharpCode.SharpDevelop
Run(args);
} catch (Exception ex) {
Console.WriteLine(ex);
Application.Run(new ExceptionBox(ex, "Unhandled exception terminated SharpDevelop"));
try {
Application.Run(new ExceptionBox(ex, "Unhandled exception terminated SharpDevelop"));
} catch {
MessageBox.Show(ex.ToString(), "Critical error (cannot use ExceptionBox)");
}
}
}
}
@ -117,7 +121,17 @@ namespace ICSharpCode.SharpDevelop @@ -117,7 +121,17 @@ namespace ICSharpCode.SharpDevelop
if (!noLogo) {
SplashScreenForm.SplashScreen.Show();
}
try {
RunApplication();
} finally {
if (SplashScreenForm.SplashScreen != null) {
SplashScreenForm.SplashScreen.Dispose();
}
}
}
static void RunApplication()
{
if (!Debugger.IsAttached) {
Application.ThreadException += ShowErrorBox;
}

3
src/Main/StartUp/Project/StartUp.csproj

@ -54,6 +54,9 @@ @@ -54,6 +54,9 @@
<EmbeddedResource Include="Resources\StringResources.resources" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<None Include="Configuration\AssemblyInfo.template" />
<None Include="SharpDevelop.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Base\Project\ICSharpCode.SharpDevelop.csproj">

56
src/Tools/UpdateAssemblyInfo/Main.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
* Time: 12:00
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
@ -16,6 +17,7 @@ namespace UpdateAssemblyInfo @@ -16,6 +17,7 @@ namespace UpdateAssemblyInfo
class MainClass
{
static Regex AssemblyVersion = new Regex(@"AssemblyVersion\(.*\)]");
static Regex BindingRedirect = new Regex(@"<bindingRedirect oldVersion=""2.0.0.1"" newVersion=""[\d\.]+""/>");
const string mainConfig = "Main/StartUp/Project/Configuration/";
public static int Main(string[] args)
@ -124,9 +126,10 @@ namespace UpdateAssemblyInfo @@ -124,9 +126,10 @@ namespace UpdateAssemblyInfo
}
if (doSetVersion) {
Console.WriteLine("Set revision to file: " + fileName + " to " + versionNumber);
SetVersionInfo(fileName, versionNumber);
SetVersionInfo(fileName, AssemblyVersion, "AssemblyVersion(\"" + versionNumber + "\")]");
}
}
SetVersionInfo("Main/StartUp/Project/SharpDevelop.exe.config", BindingRedirect, "<bindingRedirect oldVersion=\"2.0.0.1\" newVersion=\"" + versionNumber + "\"/>");
}
#region SearchDirectory
@ -156,30 +159,17 @@ namespace UpdateAssemblyInfo @@ -156,30 +159,17 @@ namespace UpdateAssemblyInfo
}
#endregion
static void SetVersionInfo(string fileName, string version)
static void SetVersionInfo(string fileName, Regex regex, string replacement)
{
StreamReader inFile = null;
string content;
try {
inFile = new StreamReader(fileName);
string content;
using (StreamReader inFile = new StreamReader(fileName)) {
content = inFile.ReadToEnd();
} catch (Exception e) {
Console.WriteLine(e);
return;
} finally {
if (inFile != null) {
inFile.Close();
}
}
if (content != null) {
string newContent = AssemblyVersion.Replace(content, "AssemblyVersion(\"" + version + "\")]");
if (newContent == content)
return;
using (StreamWriter outFile = new StreamWriter(fileName, false, Encoding.UTF8)) {
outFile.Write(newContent);
}
string newContent = regex.Replace(content, replacement);
if (newContent == content)
return;
using (StreamWriter outFile = new StreamWriter(fileName, false, Encoding.UTF8)) {
outFile.Write(newContent);
}
}
@ -191,20 +181,30 @@ namespace UpdateAssemblyInfo @@ -191,20 +181,30 @@ namespace UpdateAssemblyInfo
using (StreamReader reader = new StreamReader(@"..\REVISION")) {
return reader.ReadLine();
}
}
catch (Exception e) {
} catch (Exception e) {
Console.WriteLine(e.Message);
throw new Exception("Cannot read revision number from file: " + e.Message);
Console.WriteLine();
Console.WriteLine("The revision number of the SharpDevelop version being compiled could not be retrieved.");
Console.WriteLine("Add svn.exe to your path to fix the problem.");
Console.WriteLine();
Console.WriteLine("Build continues with revision number '9999'...");
try {
Process[] p = Process.GetProcessesByName("msbuild");
if (p != null && p.Length > 0) {
System.Threading.Thread.Sleep(3000);
}
} catch {}
return "9999";
}
}
static void RetrieveRevisionNumber()
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("svn", "info");
ProcessStartInfo psi = new ProcessStartInfo("svn", "info");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
try {
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
Process process = Process.Start(psi);
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
@ -217,7 +217,7 @@ namespace UpdateAssemblyInfo @@ -217,7 +217,7 @@ namespace UpdateAssemblyInfo
throw new Exception("Could not find revision number in svn output");
}
} catch (Exception e) {
Console.WriteLine(e.Message);
Console.WriteLine("Starting svn.exe failed: " + e.Message);
revisionNumber = ReadRevisionFromFile();
}
if (revisionNumber == null || revisionNumber.Length == 0 || revisionNumber == "0") {

1
src/Tools/UpdateAssemblyInfo/Readme.txt

@ -0,0 +1 @@ @@ -0,0 +1 @@
Read doc/technotes/Versioning.html

1
src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj

@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="Readme.txt" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

6
src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.sln

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.232
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateAssemblyInfo", "UpdateAssemblyInfo.csproj", "{605C8CDB-F0AD-4A21-9F4A-959B8DECB0F3}"
EndProject
Global
EndGlobal
Loading…
Cancel
Save