对象初始化器格式

时间:2013-08-09 16:58:43

标签: resharper resharper-8.0 reformatting object-initializer

Resharper 8中的哪些设置正在重新格式化我的对象初始值设定项? (即用逗号表示自己的行)。

var snowDepthProcessor = new DataProcessor<SnowDepthModel>
{
    Name = "Snow Depth"
    ,
    DataRetriever = snowReportRetriever
    ,
    Parser = new SnowDepthParser()
    ,
    ...
};

我已经尝试了我能找到/想到的每种设置组合;我确实希望这些行被切断但我不希望逗号在它自己的行上。

1 个答案:

答案 0 :(得分:0)

我分担你的痛苦。我承认我的解决方案只是部分解决方案,因为它需要改变你想要使用的方式

// Way safer than string comparison against "BUILTIN\\Administrators"
IdentityReference BuiltinAdministrators = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);

// Grab ACL from file
FileSecurity FileACL = File.GetAccessControl(TargetFilePath);

// Check if correct owner is set
if (FileACL.GetOwner(typeof(SecurityIdentifier)) != BuiltinAdministrators)
{
    // If not, make it so!
    FileACL.SetOwner(BuiltinAdministrators);
}

foreach (FileSystemAccessRule fsRule in FileACL.GetAccessRules(true, false, typeof(SecurityIdentifier)))
{
    // Check if rule grants delete
    if ((fsRule.FileSystemRights & FileSystemRights.Delete) == FileSystemRights.Delete)
    {
        // If so, nuke it!
        FileACL.RemoveAccessRule(fsRule);
    }
}

// Add a single explicit rule to allow FullControl
FileACL.AddAccessRule(new FileSystemAccessRule(BuiltinAdministrators, FileSystemRights.FullControl, AccessControlType.Allow));

// Enable protection from inheritance, remove existing inherited rules
FileACL.SetAccessRuleProtection(true, false);

// Write ACL back to file
File.SetAccessControl(TargetFilePath, FileACL);

然后不会更改格式。我也非常宁愿使用您已经描述的语法,因此我创建了R#ticket https://youtrack.jetbrains.com/issue/RSRP-453704,但在解决之前,这只是如何抑制它(它的行为方式)同样的方式,即使在最新的R#10)

List<string> demo = new List<string> { "a", "b", "c" } 好消息。似乎从EDIT:

开始修复