中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

Visual Studio 2005 デザイナがpartialで変わります。 不安と期待

新規プロジェクトを作成するとVisual Studio.Net 2003では

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
 /// 
 /// Form1 の概要の説明です。
 /// 
 public class Form1 : System.Windows.Forms.Form
 {
  /// 
  /// 必要なデザイナ変数です。
  /// 
  private System.ComponentModel.Container components = null;
  public Form1()
  {
   //
   // Windows フォーム デザイナ サポートに必要です。
   //
   InitializeComponent();
   //
   // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
   //
  }
  /// 
  /// 使用されているリソースに後処理を実行します。
  /// 
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null) 
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }
  #region Windows フォーム デザイナで生成されたコード 
  /// 
  /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
  /// コード エディタで変更しないでください。
  /// 
  private void InitializeComponent()
  {
   this.components = new System.ComponentModel.Container();
   this.Size = new System.Drawing.Size(300,300);
   this.Text = "Form1";
  }
  #endregion
  /// 
  /// アプリケーションのメイン エントリ ポイントです。
  /// 
  [STAThread]
  static void Main() 
  {
   Application.Run(new Form1());
  }
 }
}

それがVisual Studio 2005では3ファイルに分割されます。

EntryPoint.cs

using System;
using System.Windows.Forms;
namespace WindowsApplication1
{
 static class EntryPoint
 {
  /// 
  /// The main entry point for the application.
  /// 
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }
 }
}

Form1.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
 /// 
 /// Summary description for form.
 /// 
 public partial class Form1 : System.Windows.Forms.Form
 {
  /// 
  /// Required designer variable.
  /// 
  private System.ComponentModel.IContainer components = null;
  public Form1()
  {
   InitializeComponent();
  }
 }
}

Form1.Designer.cs

namespace WindowsApplication1
{
 public partial class Form1 : System.Windows.Forms.Form
 {
  /// 
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// 
  private void InitializeComponent()
  {
   this.components = new System.ComponentModel.Container();
   this.Size = new System.Drawing.Size(300, 300);
   this.Text = "Form1";
   this.Padding = new System.Windows.Forms.Padding(9);
   this.AutoSize = true;
  }
  /// 
  /// Clean up any resources being used.
  /// 
  protected override void Dispose(bool disposing)
  {
   if (disposing)
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose(disposing);
  }
 }
}

EntryPointは前々からそうなってほしいと思っていたのでいいとしてポイントはForm1です。

2003だと、いろいろと自動で挿入されるソースが入っているのですが2005だとシンプルになっています。

これで自分の作るソースとデザイナで設定されるソースが分割されるのでわかりやすいと思います。

でも、今のデザイナとかでデザイナ部分のソースを変更している途中の解釈失敗とかで消えてしまったりといったトラブルはこれによってより強まってしまわないか心配です。

このDesignerソース実は標準では見えない扱いで見えないファイルを表示するにしないといけません。

VSS2004もメインソースに繋がる子ファイルたちは比較できないし。(DataSetの.csファイルとかも一緒ね)

VSS2004のUTF-8対応ともどもWishした方がいいのかなーどうでしょう皆さん

投稿日時 : 2004年5月9日 0:19

コメントを追加

# Come http://www.gladesoutpost.org/appartamento-abruzzo.php ancora http://www.gladesoutpost.org/mount-gambier-realestate.php si,. 2008/04/23 20:46 Come http://www.gladesoutpost.org/appartamento-abr

Come http://www.gladesoutpost.org/appartamento-abruzzo.php ancora http://www.gladesoutpost.org/mount-gambier-realestate.php si,.

タイトル
名前
URL
コメント