Click here to Skip to main content
15,900,816 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Spelunking through C# Pin
honey the codewitch3-Dec-19 4:26
mvahoney the codewitch3-Dec-19 4:26 
GeneralWSO CCC OTD 2019-12-03 Solution Pin
OriginalGriff3-Dec-19 1:51
mveOriginalGriff3-Dec-19 1:51 
GeneralRe: WSO CCC OTD 2019-12-03 Solution Pin
musefan3-Dec-19 2:35
musefan3-Dec-19 2:35 
GeneralRe: WSO CCC OTD 2019-12-03 Solution Pin
OriginalGriff3-Dec-19 2:52
mveOriginalGriff3-Dec-19 2:52 
GeneralRe: WSO CCC OTD 2019-12-03 Solution Pin
super3-Dec-19 3:11
professionalsuper3-Dec-19 3:11 
GeneralRe: WSO CCC OTD 2019-12-03 Solution Pin
OriginalGriff3-Dec-19 3:19
mveOriginalGriff3-Dec-19 3:19 
GeneralRe: WSO CCC OTD 2019-12-03 Solution Pin
musefan3-Dec-19 4:05
musefan3-Dec-19 4:05 
RantJust because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 1:30
mvahoney the codewitch3-Dec-19 1:30 
In C#, this is valid:

C#
class A<T> {
   class B<TT> {
   }
}


therefore, this is valid:

C#
typeof(A<int>.B<int>)


The trouble is, there's absolutely nothing out there online I can find about representing such a nested generic typereference as a CodeTypeReference properly.

Which leads me to an arcane comment in Microsoft's reference sourcecode - the last hope of the desperate.

C#
// Try find the matching '[', if we can't find it, we will not try to parse the string
while (current >= 0)
{
	if (typeName[current] == '[')
	{
		// break if we found matched brackets
		if (--unmatchedRightBrackets == 0) break;
	}
	else if (typeName[current] == ']')
	{
		++unmatchedRightBrackets;
	}
	else if (typeName[current] == ',' && unmatchedRightBrackets == 1)
	{
		//
		// Type name can contain nested generic types. Following is an example:
		// System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089], 
		//          [System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], 
		//           mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
		// 
		// Spliltting by ',' won't work. We need to do first-level split by ','. 
		//
		if (current + 1 < subTypeNameEndIndex)
		{
			subTypeNames.Push(typeName.Substring(current + 1, subTypeNameEndIndex - current - 1));
		}

		subTypeNameEndIndex = current;

	}
	--current;
}


So now I get to figure out what this is doing, just so I can figure out how to properly use what it is implementing.

Microsoft Docs: Technically correct, but practically useless. Mad | :mad:
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
OriginalGriff3-Dec-19 1:50
mveOriginalGriff3-Dec-19 1:50 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 1:52
mvahoney the codewitch3-Dec-19 1:52 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
OriginalGriff3-Dec-19 2:20
mveOriginalGriff3-Dec-19 2:20 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 2:21
mvahoney the codewitch3-Dec-19 2:21 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
CPallini3-Dec-19 1:56
mveCPallini3-Dec-19 1:56 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 1:57
mvahoney the codewitch3-Dec-19 1:57 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
CPallini3-Dec-19 2:30
mveCPallini3-Dec-19 2:30 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
Rage3-Dec-19 2:03
professionalRage3-Dec-19 2:03 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 2:04
mvahoney the codewitch3-Dec-19 2:04 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
Sander Rossel3-Dec-19 2:07
professionalSander Rossel3-Dec-19 2:07 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 2:08
mvahoney the codewitch3-Dec-19 2:08 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
OriginalGriff3-Dec-19 2:22
mveOriginalGriff3-Dec-19 2:22 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 2:23
mvahoney the codewitch3-Dec-19 2:23 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
OriginalGriff3-Dec-19 2:57
mveOriginalGriff3-Dec-19 2:57 
GeneralRe: Just because nobody does something doesn't mean nobody should document that something Pin
honey the codewitch3-Dec-19 2:59
mvahoney the codewitch3-Dec-19 2:59 
GeneralDid you ever serve your guests a cold dog? Pin
CodeWraith3-Dec-19 1:01
CodeWraith3-Dec-19 1:01 
GeneralRe: Did you ever serve your guests a cold dog? Pin
kalberts3-Dec-19 23:14
kalberts3-Dec-19 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   494 votes