문제

All Visual Studios (2012 too) do not format the following:

_messageProcessor = new Dictionary<ServerDataTypes, MessageProcessor>()
{
    {ServerDataTypes.FrameData,       ProcessFrameData  }   ,
    {    ServerDataTypes.ServerStatusResult,ProcessServerStatusResult     },
    {   ServerDataTypes.PlayerMessage,    ProcessPlayerMessage},
    ....
};

How can I make my Visual Studio 2010 (or 2012) to auto-format that? I need the following result:

_messageProcessor = new Dictionary<ServerDataTypes, MessageProcessor>()
{
    { ServerDataTypes.FrameData, ProcessFrameData },
    { ServerDataTypes.ServerStatusResult, ProcessServerStatusResult },
    { ServerDataTypes.PlayerMessage, ProcessPlayerMessage },
     ...
};

It's like in the auto-properties for the newly created objects. The format is working for that. But not for this. So, how to fix it?

도움이 되었습니까?

해결책

Short answer: you can't with VS out of the box. Resharper comes close, but it's reformatting doesn't quite do this style either. I've actually submitted a request for it do do this.

You might look for some other extension or perhaps develop a macro of some sort.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top