maximum number of methods supported in C# class
-
Just curiosity ;) , Did anyone have idea of how many methods a single C# class can allow ? I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ? Thanks, Vythees
-
Just curiosity ;) , Did anyone have idea of how many methods a single C# class can allow ? I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ? Thanks, Vythees
vytheeswaran wrote:
Did anyone have idea of how many methods a single C# class can allow ?
I think that if you ever reached that limit then you might want to seriously reconsider your design.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website
-
Where does that article answer the OP's question? Or did you just chuck some keywords in to Google and hit "I'm feeling lucky"?
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website
-
-
Just curiosity ;) , Did anyone have idea of how many methods a single C# class can allow ? I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ? Thanks, Vythees
I just had a search through MS's C# Comiler errors/warnings list http://msdn2.microsoft.com/en-us/library/ms228373(VS.80).aspx[^] and can't see anything that explicitly complains about too many methods being in a class.
-
Just curiosity ;) , Did anyone have idea of how many methods a single C# class can allow ? I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ? Thanks, Vythees
Seeing Assembly metatokens takes the following form: 00 000000, where the former is the type, and the latter is the code, I would say the maximum number of methoddef's in an assembly would be limited to 24-bits, iow 16.7 million. Dunno if there is a limitation on a classes though.
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
Just curiosity ;) , Did anyone have idea of how many methods a single C# class can allow ? I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ? Thanks, Vythees
when in trouble, switch to Win64. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
vytheeswaran wrote:
Did anyone have idea of how many methods a single C# class can allow ?
I think that if you ever reached that limit then you might want to seriously reconsider your design.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website
-
Seeing Assembly metatokens takes the following form: 00 000000, where the former is the type, and the latter is the code, I would say the maximum number of methoddef's in an assembly would be limited to 24-bits, iow 16.7 million. Dunno if there is a limitation on a classes though.
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
Thanks for Info, But I read in one article that E-Bay once hits the compiler limit in max number of methods in single class. Thanks, Vythees
IIRC ebay is running its servers using c++ and ISAPI, not .net.
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
-
when in trouble, switch to Win64. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
IIRC ebay is running its servers using c++ and ISAPI, not .net.
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
-
-
Seeing Assembly metatokens takes the following form: 00 000000, where the former is the type, and the latter is the code, I would say the maximum number of methoddef's in an assembly would be limited to 24-bits, iow 16.7 million. Dunno if there is a limitation on a classes though.
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
Not research, I know it from working with the spec :) And those values can be accessed from .NET 2 (nowadays).
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
There is a limit, I remember someone a while ago (I've got a feeling in this forum) hit a limit on the number of fields in anycase that they could include in a class. Buggered if I can remember where it was or what it was :sigh:
Maybe you are thinking about the parameter limit, that is 16383/4.
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
Maybe you are thinking about the parameter limit, that is 16383/4.
**
xacc.ide-0.2.0.75 - now with C# 3.5 support and Navigation Bar!
**
-
Just curiosity ;) , Did anyone have idea of how many methods a single C# class can allow ? I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ? Thanks, Vythees
I let this run for an hour to get to 5000 before I gave up. Someone with more CPU and physical RAM than I have should run it and see where it ends...
using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom.Compiler;
namespace MethodCountLimitFinder {
class Program {
static void Main(string[] args) {
Int32 methodCount = 1;
Microsoft.CSharp.CSharpCodeProvider cscp = new Microsoft.CSharp.CSharpCodeProvider();
ICodeCompiler icc = cscp.CreateCompiler();
CompilerParameters cp = new CompilerParameters();
cp.GenerateExecutable = false;
cp.GenerateInMemory = true;
CompilerResults cr = null;
string pre = "using System;" + Environment.NewLine +
Environment.NewLine +
"namespace Tester {" + Environment.NewLine +
" class Test {" + Environment.NewLine;
string post = " }" + Environment.NewLine +
"}";
string inner = string.Empty;
while (true) {
inner += " public Int32 Method" + methodCount.ToString() + "() {" + Environment.NewLine +
" return 42;" + Environment.NewLine +
" }" + Envi -
I let this run for an hour to get to 5000 before I gave up. Someone with more CPU and physical RAM than I have should run it and see where it ends...
using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom.Compiler;
namespace MethodCountLimitFinder {
class Program {
static void Main(string[] args) {
Int32 methodCount = 1;
Microsoft.CSharp.CSharpCodeProvider cscp = new Microsoft.CSharp.CSharpCodeProvider();
ICodeCompiler icc = cscp.CreateCompiler();
CompilerParameters cp = new CompilerParameters();
cp.GenerateExecutable = false;
cp.GenerateInMemory = true;
CompilerResults cr = null;
string pre = "using System;" + Environment.NewLine +
Environment.NewLine +
"namespace Tester {" + Environment.NewLine +
" class Test {" + Environment.NewLine;
string post = " }" + Environment.NewLine +
"}";
string inner = string.Empty;
while (true) {
inner += " public Int32 Method" + methodCount.ToString() + "() {" + Environment.NewLine +
" return 42;" + Environment.NewLine +
" }" + EnviSean Michael Murphy wrote:
while (true) { inner += " public Int32 Method" + methodCount.ToString() + "() {" + Environment.NewLine + " return 42;" + Environment.NewLine + " }" + Environment.NewLine; cr = icc.CompileAssemblyFromSource(cp, pre + inner + post); if (cr.Errors.Count > 0) break; methodCount++; if (methodCount % 10 == 0) System.Console.WriteLine(methodCount.ToString()); }
Sean Michael Murphy wrote:
Someone with more CPU and physical RAM than I have should run it and see where it ends...
No wonder, always use StringBuilder for string concatenation in a loop.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe