漫坊亭@ウィキ
http://w.atwiki.jp/jfactory/
漫坊亭@ウィキja2014-06-09T15:54:27+09:001402296867トップページ/CSHARP/StyleCop
https://w.atwiki.jp/jfactory/pages/57.html
|&big(){StyleCop}|
#contents()
----
*設定
-SA1027が、いつの間にかOFFにできるようになった(@@
&s(){SA1027をOFFにしたいが、それはできないようだ。つまりタブは使えず、すべてスペースにしろってことらしい。}
-SA1630はOFFにしないと不都合がある。これは、「summaryタグ内の文字列にスペースがない」というエラーで、英文は区切りがスペースであり、それがないということは、ドキュメントがちゃんと書かれていないかも、ということを示している。日本語は句読点で区切ることができるため、ちゃんと書いてあってもこのエラーに引っかかる。
-SA1631はOFFにしないと不都合がある。これは、「summaryタグ内が、適切な文法構造に従うようには見えない」というエラーで、シンボルと非英字の割合で算出される。つまり、日本語とは関係ない。
----
*ヘッダーの例
<copyright file="AssemblyInfo.cs" company="J-FACTORY">(C)2012</copyright>
----
*ファイルを除外
プロジェクトファイル(.csproj)に細工をする
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>
</ItemGroup>
ファイル先頭に下記を追加する(こっちのが簡単)
// <auto-generated />
----
*行やブロックを除外
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented",
Justification = "抑制する理由を書く")]
----
*参考
http://stylecop.soyuz5.com/StyleCop%20Rules.html
----
*1000 Spacing Rules
Microsoft.StyleCop.CSharp.SpacingRules
|SA1000|SA1000:KeywordsMustBeSpacedCorrectly&br()A violation of this rule occurs when the spacing around a keyword is incorrect.|
|SA1001:CommasMustBeSpaceCorrectly|The spacing around a comma is incorrect, within a C# code file.|
|SA1002:SemicolonsMustBeSpaceCorrectly|Invalid spacing around the semicolon.&br()セミコロンの前後の間隔が無効です。|
|SA1003:SymbolsMustBeSpaceCorrectly|The spacing around the symbol '+' is invalid.&br()'+'というシンボルの周りのスペースは無効です。|
|SA1004:DocumentationLinesMustBeginWithSingleSpace|The documentation header line must start with a single space.&br()ドキュメンテーションヘッダーの行は、シングルスペースから始まらなければなりません。|
|SA1005:SingleLineCommentsMustBeginWithSingleSpace|The comment must start with a single space. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.&br()コメントはシングルスペースから始まらなければなりません。コードの行をコメントアウトするときこのエラーを無視するには、'//'よりむしろ'////'でコメントを始めてください。|
|SA1006:PreprocessorKeywordsMustNotBePrecededBySpace|A violation of this rule occurs when the preprocessor-type keyword in a preprocessor directive is preceded by space.|
|SA1007:OperatorKeywordMustBeFollowedBySpace|A violation of this rule occurs when the operator keyword within an operator overload method is not followed by any whitespace. The operator keyword should always be followed by a single space.|
|SA1008:OpeningParenthesisMustBeSpacedCorrectly|A violation of this rule occurs when the opening parenthesis within a statement is not spaced correctly.|
|SA1009:ClosingParenthesisMustBeSpacedCorrectly|Invalid spacing around the closing parenthesis.&br()閉じ括弧の周りの無効のスペース|
|SA1010:OpeningSquareBracketsMustBeSpacedCorrectly|A violation of this rule occurs when an opening square bracket within a statement is preceded or followed by whitespace.|
|SA1011:ClosingSquareBracketsMustBeSpacedCorrectly|A violation of this rule occurs when the spacing around a closing square bracket is not correct.|
|SA1012:OpeningCurlyBracketsMustBeSpacedCorrectly|Invalid spacing around the opening curly bracket.&br()初めの中括弧の周りの無効のスペース。|
|SA1025:CodeMustNotContainMultipleWhitespaceInARow|The code contains multiple spaces in a row. Only one space is needed.&br()このコード行で複数のスペースが含まれています。唯一の1つのスペースが必要です。|
|SA1027:TabsMustNotBeUsed|Tabs are not allowed. Use spaces instead.&br()タブは許容されていません。 代わりにスペースを使用してください。|
----
*1100 Readability Rules
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "*", Justification = "")]
|SA1100|SA1100:DoNotPrefixCallsWithBaseUnlessLocalImplementationExists&br()継承されたクラスのメンバーへの呼び出しはbaseで始まらなくてはならない。|
|SA1101|The call to components must begin with the 'this.' prefix to indicate that the item is a member of the class.&br()アイテムがクラスの一員であることを示すために、コンポーネントへの呼び出しは'this'接頭語で始めなければなりません。|
|SA1108|SA1108:BlockStatementsMustNotContainEmbeddedComments&br()コメントは括弧の中に置かなければなりません。|
|SA1115|The parameter must begin on the line after the previous parameter.&br()パラメタは前のパラメタの後の行の上で始まらなければなりません。|
|SA1116|If the method parameters are on separate lines, the first parameter must begin on the line beneath the name of the method.&br()メソッドパラメタが別々の行にあるなら、最初のパラメタはメソッド名の下の位置で始まらなければなりません。|
|SA1117|All method parameters must be placed on the same line, or each parameter must be placed on a separate line.&br()すべてのメソッドのパラメータは同じ行に配置するか、各パラメータごとに別の行に配置する必要があります。|
|SA1119|The line contains unnecessary parenthesis.&br()不必要な括弧の行を含んでいます。|
|SA1120|The comment is empty. Add text to the comment or remove it.&br()コメントは空です。コメントにテキストを追加または削除してください。|
|SA1121|Use the built-in type alias 'byte' rather than Byte or System.Byte.&br()ByteやSystem.Byteよりむしろ内蔵型別名'byte'を使用してください。&br()int,uint,short,ushort...|
|SA1122|Use string.Empty rather than "".&br()""よりstring.Emptyを使用してください。|
|SA1123|The use of regions is not allowed within code elements. Remove the #region and #endregion tags.&br()regionの使用はコード要素の中で許されていません。 #regionと#endregionタグを取り除いてください。|
----
*1200 Ordering Rules
Microsoft.StyleCop.CSharp.OrderingRules
|SA1200|All "using directives" must be placed inside of the namespace.&br()すべてのusingディレクティブは名前空間の内部に置かなければなりません。|
|SA1201|All constructors must be placed after all fields.&br()すべてのフィールドの後にすべてのコンストラクタを置かなければなりません。&br()●ファイル内の順番&br()Extern Alias&br()Directives&br()Using Directives&br()名前空間(Namespaces)&br()デリゲート(Delegates)&br()列挙型(Enums)&br()インターフェイス(Interfaces)&br()構造体(Structs)&br()クラス(Classes)&br()●クラスか構造体かインターフェイス内の順番&br()メンバ(Fields)&br()コンストラクタ(Constructors)&br()デストラクタ(Finalizers (Destructors))&br()デリゲート(Delegates)&br()イベント(Events)&br()列挙型(Enums)&br()インターフェイス(Interfaces)&br()プロパティ(Properties)&br()インデクサ(Indexers)&br()メソッド(Methods)&br()構造体(Structs)&br()クラス(Classes)|
|SA1202|All protected methods must be placed after all public methods.&br()すべてのprotectedメソッドはpublicメソッドの後ろに置かなければなりません。|
|SA1203|All constant and readonly private fields must be placed before all non-constant, non-readonly private fields.&br()すべての定数と読み取り専用プライベートフィールドは、非定数と非読み取り専用プライベートフィールドよりも前に配置する必要があります。|
|SA1204|All static private fields must be placed before all non-static private fields.&br()すべての静的なプライベートフィールドの前に全ての非静的プライベートフィールドを配置する必要があります。|
|SA1205|SA1205:PartialElementsMustDeclareAccess&br()The partial element does not have an access modifier defined.&br()部分的な要素は、アクセス修飾子を定めておきません。|
|SA1206|SA1206:DeclarationKeywordsMustFollowOrder&br()The access modifier keyword must come before the 'static' keyword in the element declaration.&br()アクセス修飾子キーワードは、要素宣言において『静的』キーワードの前に来なければなりません。|
|SA1210|Using directives must be sorted alphabetically by the namespaces.&br()using は名前空間のアルファベット順にソートされていなければなりません。|
----
*1300 Naming Rules
Microsoft.StyleCop.CSharp.NamingRules
|SA1300|method names begin with an upper-case letter: XXX&br()メソッド名は大文字アルファベットで始まります|
|SA1305|The variable name 'hByte2' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed prefixes.&br()変数名'hByte2'はハンガリーの記法に似ている接頭語で始まります。 接頭語を移すか、または許容接頭語のリストにそれを追加してください。|
|SA1306|Variable names must start with a lower-case letter: 変数名.&br()変数名は小文字アルファベットから始まらなければなりません|
|SA1307|Public and internal fields must start with an upper-case letter.&br()public、そして、internalのフィールドは大文字アルファベットから始まらなければなりません|
----
*1400 Maintainability Rules
Microsoft.StyleCop.CSharp.MaintainabilityRules
|SA1400|The class must have an access modifier.&br()クラスには、アクセス修飾語がなければなりません。|
|SA1401|SA1401:SA1401:FieldsMustBePrivate&br()Fields must be declared with private access. Use properties to expose fields.&br()プライベートでフィールドを申告しなければなりません。 プロパティを使用でフィールドを公開してください。|
|SA1402|SA1402:FileMayOnlyContainASingleClass&br()A violation of this rule occurs when a C# file contains more than one class.&br()ファイルはクラスをひとつだけ含むべきである|
|SA1404|A Code Analysis suppression must contain a non-empty justification describing the reason for the suppression.&br()コード解析の抑制、非空の正当性を抑制するための理由を記述する必要があります。|
|SA1405|A call to Debug.Assert must provide a message in the second parameter describing the reason for the assert.&br()Debug.Assertの呼び出しは、2番目のパラメータにassertの理由を表すメッセージを記述する必要があります。|
|SA1407|Insert parenthesis within the arithmetic expression to declare the operator precedence.&br()算術式の中に丸括弧を挿入して、演算子の優先順位を明確にしてください。|
----
*1500 Layout Rules
Microsoft.StyleCop.CSharp.LayoutRules
|SA1500|If a statement spans multiple lines, the opening curly bracket must be placed on its own line.&br()ステートメントが複数の行にかかっているなら、初めの中括弧をそれ自身の行に置かなければなりません。|
|SA1501|A statement containing curly brackets must not be placed on a single line. The opening and closing curly brackets must each be placed on their own line.&br()SA1501: 中括弧を含むステートメントを一行に置いてはいけません。 それぞれそれら自身の線に中括弧を置かなければなりません。|
|SA1502|SA1502:ElementMustNotBeOnASingleLine&br()The constructor must not be placed on a single line. The opening and closing curly brackets must each be placed on their own line.&br()コンストラクタを一行に置いてはいけません。 それぞれ初めの、そして、終わりの中括弧をそれら自身の線に置かなければなりません。|
|SA1503|The body of the if statement must be wrapped in opening and closing curly brackets.&br()本体は、中括弧でステートメントを包装しなければならない。|
|SA1505|An opening curly bracket must not be followed by a blank line.&br()空白行は初めの中括弧のあとに続いてはいけません。|
|SA1506|A documentation header line must not be followed by a blank line.&br()空白行はドキュメンテーションヘッダー行のあとに続いてはいけません。|
|SA1507|The code must not contain multiple blank lines in a row.&br()このコード行で、複数の空白行を含めることはできません。|
|SA1508|The code must not contain blank lines at the end of the file.&br()ファイル最後に空行を含んではなりません。|
|SA1510|An else, catch, or finally statement must not be preceded by a blank line.&br()else、catch、finallyステートメントは、空白行が先行することはできません。|
|SA1512| A single-line comment must not be followed by a blank line. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.&br()空白行は一行コメントのあとに続いてはいけません。コメントはシングルスペースから始まらなければなりません。コードの行をコメントアウトするときこのエラーを無視するには、'//'よりむしろ'////'でコメントを始めてください。|
|SA1513|Statements or elements wrapped in curly brackets must be followed by a blank line.&br()中括弧で囲まれたステートメントかエレメントは、空白行が続かなければなりません。|
|SA1514|A documentation header must be preceded by a blank line or must be the first item in its scope.&br()ドキュメンテーションヘッダーは、空白行が先行しなければならない、さもなければ、範囲で最初の項目であるに違いありません。|
|SA1515|A single-line comment must be preceded by a blank line or another single-line comment, or must be the first item in its scope. To ignore this error when commenting out a line of code, begin the comment with '////' rather than '//'.&br()SA1515: 1行のコメントは、空白行か別の単線コメントで先行しなければならないか、または範囲で最初の項目であるに違いありません。コメントはシングルスペースから始まらなければなりません。コードの行をコメントアウトするときこのエラーを無視するには、'//'よりむしろ'////'でコメントを始めてください。|
|SA1516|Adjacent elements must be separated by a blank line.&br()隣接するエレメントは、空白行で切り離さなければなりません。|
----
*1600 Documentation Rules
Microsoft.StyleCop.CSharp.DocumentationRules
|SA1600|The class must have a documentation header.&br()The method must have a documentation header.&br()クラス(メソッド)には、ドキュメンテーションヘッダーがなければなりません。|
|SA1601|The partial class element must have a documentation header containing either a summary tag or a content tag.&br()partial class要素には、summaryタグかcontentタグのどちらかを含むドキュメンテーションヘッダーがなければなりません。|
|SA1606|The summary section in the documentation header must not be empty.&br()ドキュメントヘッダーの概要のセクションを空にすることはできません。|
|SA1611|The documentation header must contain param tags matching the element's parameter list.&br()ドキュメンテーションヘッダーは要素のパラメータ・リストに合っているparamタグを含まなければなりません。|
|SA1612|The param tags in the documentation header must match the element's parameter list.&br()ドキュメンテーションヘッダーのparamタグは要素のパラメータ・リストに合わなければなりません|
|SA1614|The documentation text within the param tag for the '<param name="hdr"></param>' parameter must not be empty.&br()ドキュメントのテキストのparamタグの'<param name="xxx"></param>'が空であってはならない。|
|SA1615|The documentation header must contain a returns tag since the element has a return value.&br()戻り値を持っているエレメントのドキュメンテーションヘッダは、リターンタグを含める必要があります。 |
|SA1623|The property's documentation summary text must begin with: Gets&br()プロパティの<summary>は以下で始まらなければなりません。 Gets ...|
|SA1625|The documentation header contains two or more identical documentation strings. The only documentation text which may be duplicated is 'The parameter is not used.'.&br()ドキュメンテーションヘッダーは2個以上の同じドキュメンテーションストリングを含んでいます。 コピーされるかもしれない唯一のドキュメンテーションテキストは'parameter is not used.'。|
|SA1630|The documentation text within the summary tag does not contain any whitespace between words, indicating that it most likely does not follow a proper grammatical structure required for documentation text.&br()summaryタグの中のドキュメンテーションテキストは単語の間のどんな空白も含んでいません、たぶん適切な文法構造がドキュメンテーションテキストに必要であるということにならないのを示しています。|
|SA1631|The documentation text within the summary tag does not appear to follow a proper grammatical structure required for documentation text.&br()summaryタグの中のドキュメンテーションテキストはドキュメンテーションテキストに必要である適切な文法構造に従うように見えません。|
|SA1632|The documentation text within the summary tag must be at least 10 characters in length. Documentation failing to meet this guideline most likely does not follow a proper grammatical structure required for documentation text.&br()summaryタグの中のドキュメンテーションテキストは少なくとも10文字の長さでなければなりません。 このガイドラインを満たさないドキュメンテーションがたぶんドキュメンテーションテキストに必要である適切な文法構造に従いません。|
|SA1633|The file has no header, the header Xml is invalid, or the header is not located at the top of the file.&br()ファイルには、ヘッダーが全くないか、ヘッダーXmlが無効であるか、またはヘッダーはファイルの先頭に位置していません。|
|SA1634|The file header must contain a copyright tag.&br()ファイル先頭には、<copyright>タグがなくてはならない|
|SA1638|The file attribute in the file header's copyright tag must contain the name of the file.&br()ファイルヘッダーのファイル属性のcopyrightタグは、ファイル名を含まなければなりません。|
|SA1642|The documentation text within the constructor's summary tag must begin with the text:Initializes a new instance of the Form1 class.&br()コンストラクタのsummaryタグの中のドキュメンテーションテキストは"Initializes a new instance of the **** class"テキストで始まらなければなりません。|
|SA1643|The documentation text within the destructor's summary tag must begin with the text: Finalizes an instance of the **** class.&br()デストラクタのsummaryタグの中のドキュメンテーションテキストは"Finalizes an instance of the **** class"テキストで始まらなければなりません。|
|SA1644|The documentation header must not contain blank lines. Use the 'para' tag to insert line breaks within documentation text.&br()空白行は、ドキュメントヘッダーに含めることはできません。ドキュメントのテキストに改行を挿入するには'para'タグを使用してください。|
|SA1649|SA1649:FileHeaderFileNameDocumentationMustMatchTypeName&br()A violation of this rule occurs when the file tag within the file header at the top of a C# file does not contain the name of the first type in the file.&br()ファイルヘッダのファイルタグに、ファイル内の最初の名前が含まれていない|
----
*VisualStudioのエディタ設定
オプションダイアログ => テキストエディタ => C#
-タブ
--インデント&br()( ) なし&br()( ) ブロック&br()(O) スマート
--タブ&br()タブサイズ = 4&br()インデントサイズ = 4&br()(O) 空白の保持&br()( ) タブの保持
-書式設定
--全般&br()[V]‘;'を入力しステートメントを終了したときにオートフォーマットする&br()[V]‘}'を入力しブロックを終了したときにオートフォーマットする&br()[V] 貼り付け時にオートフォーマットする
--インデント&br()[V] ブロックの内容をインデントする&br()[ ] 初めと終わりのかっこをインデントする&br()[V] caseの内容をインデントする&br()[ ] caseのラベルをインデントする
---ラベルインデント&br()( ) gotoラベルを左端の列に配置する(O) gotoラベルを現在より1インデントだけ下げて配置する&br()( ) ラベルを標準にインデントする
--改行
---中かっこの改行オプション&br()[V] 新しい行に始めかっこを配置する&br()[V] 新しい行にメソッドの始めかっこを配置する&br()[V] 新しい行に匿名メソッドの始めかっこを配置する&br()[V] 新しい行にコントロールブロックの始めかっこを配置する&br()[V] 新しい行に匿名型の始めかっこを配置する&br()[V] 新しい行にオブジェクト初期化子の始めかっこを配置する&br()[V] 新しい行にラムダ式の始めかっこを配置する
---キーワードの改行オプション&br()[V] 新しい行に"else"を配置する&br()[V] 新しい行に"catch"を配置する&br()[V] 新しい行に"finally"を配置する
---式の改行オプション&br()[V] 新しい行にオブジェクト初期化子のメンバを配置する&br()[V] 新しい行に匿名型のメンバを配置する&br()[V] 新しい行にクエリ式の句を配置する
--行間
---メソッド宣言子のスペースを設定する&br()[ ] メソッド名と初めのかっこの間にスペースを挿入する&br()[ ] 引数リストのかっこ内にスペースを挿入する[ ] 空の引数リストのかっこ内にスペースを挿入する
---メソッド呼び出しのスペースを設定する&br()[ ] メソッド名と初めかっこの間にスペースを挿入する&br()[ ] 引数リストのかっこ内にスペースを挿入する&br()[ ] 空の引数リストのかっこ内にスペースを挿入する
---その他のスペースオプションを設定する&br()[V] 制御フローステートメント内のキーワードの後にスペースを挿入する&br()[ ] 式のかっこ内にスペースを挿入する&br()[ ] 型キャストのかっこ内にスペースを挿入する&br()[ ] 制御フローステートメントのかっこ内にスペースを挿入する&br()[ ] キャストの後にスペースを追加する&br()[V] 宣言ステートメント内のスペースを無視する&br()
---大かっこのスペースを設定する&br()[ ] 初め角かっこの前にスペースを挿入する&br()[ ] 空の角かっこ内にスペースを挿入する&br()[ ] 角かっこ内にスペースを挿入する
---区切り記号のスペースを設定する&br()[V] 型宣言で、基本またはインターフェイス用のコロンの後にスペースを配置する&br()[V] コンマの後にスペースを追加する&br()[ ] ピリオドの後にスペースを追加する&br()[V] "for"ステートメントでセミコロンの後にスペースを挿入する&br()[V] 型宣言で、基本またはインターフェイス用のコロンの前にスペースを挿入する&br()[ ] コンマの前にスペースを挿入する&br()[ ] ピリオドの前にスペースを挿入する&br()[ ] "for"ステートメントの前にスペースを挿入する
---演算子のスペースを設定する&br()(O) バイナリ演算子の前後にスペースを挿入する&br()( ) バイナリ演算子の前後のスペースを無視する&br()( ) バイナリ演算子の前後のスペースを削除する
---折り返し&br()[V] ブロックを単一行に配置する&br()[V] 1行に複数のステートメントとメンバ宣言を表示する 2014-06-09T15:54:27+09:001402296867トップページ
https://w.atwiki.jp/jfactory/pages/1.html
プログラミングメモ(^^
YAGNI : You Aren't Going to Need It
あなたはそれを必要としないだろう
#comment()
|W|何(What)|聞き手に何を知って欲しいのか|
|I|興味(Interest)|言いたいことの中にある彼らの興味とは何か|
|S|洗練(Sophisticate)|それはどれくらい洗練されているか|
|D|詳細(Detail)|彼らはどの程度詳細を知りたがっているか|
|O|誰の情報(Own)|誰にその情報を知ってもらいたいのか|
|M|動機付け(Motivate)|話を聞いてもらえるには、どうするのか|
|読み方 |小|大|読み方 |小|大|読み方 |小|大|
|アルファ |α|Α|イオタ |ι|Ι|ロー |ρ|Ρ|
|ベータ |β|Β|カッパ |κ|Κ|シグマ |σ|Σ|
|ガンマ |γ|Γ|ラムダ |λ|Λ|タウ |τ|Τ|
|デルタ |δ|Δ|ミュー |μ|Μ|ウプシロン |υ|Υ|
|イプシロン |ε|Ε|ニュー |ν|Ν|ファイ |φ|Φ|
|ゼータ |ζ|Ζ|クサイ |ξ|Ξ|カイ |χ|Χ|
|イータ |η|Η|オミクロン |ο|Ο|プサイ |ψ|Ψ|
|シータ |θ|Θ|パイ |π|Π|オメガ |ω|Ω|
#co(){
http://www.aoky.net/articles/jeff_atwood/the_programmers_bill_of_rights.htm
http://www.aoky.net/articles/jeff_atwood/top_6_list_of_programming_top_10_lists.htm
}
2014-01-06T10:36:45+09:001388972205トップページ/INNO
https://w.atwiki.jp/jfactory/pages/75.html
|&big(){Inno Setup}|
[[Download Inno Setup>http://www.jrsoftware.org/isdl.php]]から、ispack-5.5.4-unicode.exeをダウンロードする。
#contents()
----
*Inno Script Studioの日本語化
こんな感じで、とりあえず目についた部分のみ日本語にしてみた。
#ref(Inno Script Studio.png)
これ&ref(InnoScriptStudio5.5.4.Japanese.zip)を展開して、
Languagesにコピーすると、日本語が選べるようになる。
デフォルトのインストールフォルダ
C:\Program Files (x86)\Inno Script Studio\Languages 2014-01-06T10:34:48+09:001388972088メニュー
https://w.atwiki.jp/jfactory/pages/2.html
|BGCOLOR(gold):[[トップページ]]|
今日来た人:&counter(today,page=メニュー)人
昨日来た人:&counter(yesterday,page=メニュー)人
今迄来た人:&counter(total,page=メニュー)人
[[Inno Setup>トップページ/INNO]]
*Windows
[[64bit>トップページ/WIN/ETC64]]
*C#
#treemenu(title=Windows.Forms,[[PropertyGrid>トップページ/CSHARP/WINFORM/PropertyGrid]])
[[WPF+Livet>トップページ/CSHARP/WpfLivet]]
[[アプリ>トップページ/CSHARP/Application]]
[[言語>トップページ/CSHARP/Language]]
[[クラス>トップページ/CSHARP/Class]]
[[ライブラリ>トップページ/CSHARP/Library]]
[[ロギング>トップページ/CSHARP/Logging]]
[[例外処理>トップページ/CSHARP/Exception]]
[[トレース>トップページ/CSHARP/Trace]]
[[小技>トップページ/CSHARP/Tips]]
[[自分用>トップページ/CSHARP/MyLib]]
*いまさらVB6
[[基本的なこと>トップページ/VB6/BASIC]]
[[いろいろ>トップページ/VB6/ETC]]
#treemenu(title=サンプル,[[サンプル>トップページ/VB6/SAMPLE]],[[パス関連>トップページ/VB6/SAMPLE_PATH]],[[ファイル関連>トップページ/VB6/SAMPLE_FILE]])
#treemenu(title=Tools,[[VisualStudio>トップページ/VS]],[[NUnit>トップページ/CSHARP/NUNIT]],[[SandCastel>トップページ/CSHARP/COMMENT]],[[StyleCop>トップページ/CSHARP/StyleCop]],[[FxCop>トップページ/CSHARP/FxCop]])
#treemenu(title=.NET,[[覚え書き>トップページ/DOTNET/MEMO]],[[いろいろ>トップページ/DOTNET/ETC]])
#treemenu(title=C#,[[自分的ルール>トップページ/CSHARP/RULE]],[[いろいろ>トップページ/CSHARP/ETC]],[[バインディング>トップページ/CSHARP/BIND]],[[ファイル操作>トップページ/CSHARP/FILE]],[[数値・文字列>トップページ/CSHARP/NUMSTR]],[[プログラム>トップページ/CSHARP/PROGRAM]],[[フォーム>トップページ/CSHARP/FORM]],[[コンポーネント>トップページ/CSHARP/COMPO]],[[画像操作>トップページ/CSHARP/IMAGE]],[[XMLコメント>トップページ/CSHARP/COMMENT]])
#treemenu(title=C++/CLI,[[いろいろ>トップページ/CPPCLI/ETC]],[[画像操作>トップページ/CPPCLI/IMAGE]],[[C/C++への橋渡し>トップページ/CPPCLI/LEGACY]],[[OpenCVで遊ぶ>トップページ/CPPCLI/OPENCV]])
#treemenu(title=C++/STL/Boost,[[いろいろ>トップページ/CPP]],[[BoostAsio>トップページ/CPP/BoostAsio]])
#treemenu(title=Linux,[[いろいろ>トップページ/LINUX]])
#treemenu(title=PLC,[[各社比較表>トップページ/PLC/COMPARE]])
#treemenu(title=国際化辞書,[[よく使うもの>トップページ/LANG/OftenUsed]],[[あ~>トップページ/LANG/A]],[[か~>トップページ/LANG/KA]],[[さ~>トップページ/LANG/SA]],[[た~>トップページ/LANG/TA]],[[な~>トップページ/LANG/NA]],[[は~>トップページ/LANG/HA]],[[ま~>トップページ/LANG/MA]],[[や~>トップページ/LANG/YA]],[[ら~>トップページ/LANG/RA]],[[わ~>トップページ/LANG/WA]])
----
**更新履歴
#recent(20) 2014-01-06T10:13:26+09:001388970806トップページ/CSHARP/WINFORM/PropertyGrid
https://w.atwiki.jp/jfactory/pages/74.html
|&big(){Windows.Forms.PropertyGrid}|
#contents()
----
*データをセットする
this.PropertyGrid.SelectedObject = データの入っているクラスのインスタンス
*デフォルト値
[DefaultValue(false)]
public bool Foo { get; set; }
*表示しない
[Browsable(false)]
public bool Foo { get; set; }
*説明表示
[Description("ここに説明を書く")]
public bool Foo { get; set; }
*グループ
FooとBarは同じグループとして表示される
[Category("友達")]
public bool Foo { get; set; }
[Category("友達")]
public bool Bar { get; set; }
*書き込めなくする
[ReadOnly(true)]
public bool Foo { get; set; }
*デフォルトプロパティ
Barにフォーカスがある状態で開始する
[DefaultProperty("Bar")]
public class Settings
{
public bool Foo { get; set; }
public bool Bar { get; set; }
}
*内包クラスを展開できるようにする
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Foo { get; set; }
*ファイルを開く
参照設定にSystem.Designを追加が必要
using System.Drawing.Design;
using System.Windows.Forms.Design;
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
public string Foo { get; set; }
2013-03-15T08:56:38+09:001363305398トップページ/CSHARP/LANGUAGE
https://w.atwiki.jp/jfactory/pages/14.html
|&big(){言語}|
#contents()
----
*(linq) オブジェクトの一括New
List<FooClass> x = Enumerable.Range(0, 5).Select((y) => new FooClass()).ToList();
List<FooClass>[] x = new List<Dummy>[5].Select((y) => new List<FooClass>()).ToArray();
List<List<FooClass>> x = Enumerable.Range(0, 5).Select((y) => new List<FooClass>()).ToList();
*(foreach) 繰り返し回数を知る
foreach (var x in table.Select((s, i) => new { i, s }))
{
Console.WriteLine("No.{0}, Data={1}", x.i, x.s.ToString());
}
*(enum) 範囲内か調べる
Enum.IsDefined 2013-03-05T22:26:55+09:001362490015トップページ/CSHARP/Tips
https://w.atwiki.jp/jfactory/pages/73.html
|&big(){小技}|
#contents()
----
*数値をbyte配列に変換(byte配列)
uint numver = 1;
byte[] byteArray = BitConverter.GetBytes(number);
*byte配列を数値に変換(byte配列)
var byteArray = new byte {0,1,2,3};
uint dwValue = BitConverter.ToUInt32(byteArray, 0);
*CSV形式の文字列をbyte配列に変換(csv,byte配列)
byte[] byteArray =
text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select((x) => Convert.ToByte(x, 16))
.ToArray();
*byte配列をCSV形式の文字列に変換(csv,byte配列)
string.Join(",", byteArray.Select(x => x.ToString("X2"))); 2013-01-25T15:37:45+09:001359095865トップページ/CSHARP/WpfLivet
https://w.atwiki.jp/jfactory/pages/72.html
|&big(){WPF+Livet}|
#contents()
----
*フォルダ選択(Livet.Extensions)
View
<Button Content="FolderDialog" Width="75">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:FolderBrowserDialogInteractionMessageAction>
<l:DirectInteractionMessage CallbackMethodTarget="{Binding}" CallbackMethodName="FolderSelected">
<l:FolderSelectionMessage Description="フォルダーの選択" DialogPreference="None"/>
</l:DirectInteractionMessage>
</l:FolderBrowserDialogInteractionMessageAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
ViewModel
public void FolderSelected(FolderSelectionMessage m)
{
System.Diagnostics.Debug.WriteLine(m.Response);
}
2013-01-11T09:26:11+09:001357863971トップページ/VB6/SAMPLE
https://w.atwiki.jp/jfactory/pages/67.html
|&big(){サンプルコード}|
#contents()
----
*自己再起動
If Not (0 = Shell(App.Path & "\" & App.EXEName)) Then End
----
*空の配列
C#でいうところの、nullが入った状態のことである。
基本的にVB6では、空っぽの配列を作成することはできない。
しかし、偉大な先人達が、いくつかの方法を見つけている。
-null?を入れておく方法
VB6にはnullなどないので、それに変わる方法を使う。
いちおうmsdnにも記載されているらしいが、かなり裏技っぽい
'Variant型の空の配列を作る
Dim arr() As Variant
arr = Array()
'空っぽの判定
On Error Resume Next
If (UBound(arr)) Then
Debug.Print "配列は空っぽ"
End If
'String型の空の配列を作る
Dim StringArray() As String
StringArray = Split("")
'Byte型の空の配列を作る
Dim ByteArray() As Byte
ByteArray = ""
'Object型の空の配列を作る
Dim ObjectArray() As Object
Call IsArray(ObjectArray)
-APIを使う方法
Private Declare Function SafeArrayAllocDescriptor Lib "oleaut32" ( _
ByVal cDims As Long, ByRef ppsaOut() As Any) As Long
Private Declare Sub GetMem4 Lib "msvbvm60" ( _
ByVal ptr As Long, ByRef ret As Long)
-「常に目的のサイズ+1とし、サイズが1を空とみなす方法」
自分的には、読みやすさも考えて、これが好ましいと考える。
Dim arr() As Integer
ReDim arr(0)
'空っぽの判定(本当は要素数1である)
If (UBound(arr) = 0) Then
'...
End If
'要素数を5に変更(本当は要素数6になる)
ReDim arr(5)
'ループ処理(cntは0~4の値となる)
Dim cnt As Integer
For cnt = 0 To UBound(arr) - 1
'...
Next cnt
'末尾に要素を追加
ReDim Preserve arr(UBound(arr) + 1)
arr(UBound(arr) - 1) = 0
----
*ビット演算
-指定位置のバイトを取り出す
'source:取り出し元 / destination:取り出したデータ
Dim source as Long, destination as Long
'最下位バイトを取り出す dest = src & 0xff
destination = source And &HFF&
'2バイト目を取り出す dest = (src >> 8) & 0xff
destination = (source / &H100) And &HFF&
'3バイト目を取り出す dest = (src >> 16) & 0xff
destination = (source / &H10000) And &HFF&
'最下位バイトを取り出す dest = (src >> 24) & 0xff
destination = (source / &H1000000) And &HFF&
----
*ファイル
Dim fno as Integer, str As String
fno = FreeFile
Open "c:\sample.txt" For Input As #fno
Line Input #fno, str
Close #fno
2011-04-06T13:59:21+09:001302065961トップページ/VB6/SAMPLE_PATH
https://w.atwiki.jp/jfactory/pages/71.html
|&big(){ファイルに関するサンプルコード}|
#contents()
----
*フルパスファイル名のパス名部分を得る
' IN: fullPathName フルパス名
' OUT: String パス名
Public Function GetPathName(ByVal fullPathName As String) As String
If PathName = "" Then Exit Function
'fullPathNameを'\'で分解する
Dim Files() As String
Files = Split(PathName, "\")
If (UBound(Files) > 0) Then
'最後の要素を削除する
ReDim Preserve Files(UBound(Files) - 1)
'Files()を連結する
GetPathName = Join(Files, "\")
Else
GetPathName = PathName
End If
End Function
----
*フルパスファイル名のファイル名部分を得る
Public Function GetFileName(ByVal fullPathName As String) As String
If PathName = "" Then Exit Function
'FileNameを'\'で分解する
Dim Files() As String
Files = Split(PathName, "\")
'最後の要素を返す
GetFileName = Files(UBound(Files))
End Function
2010-12-28T09:23:51+09:001293495831