referencesource
Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework
Top Related Projects
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Mono open source ECMA CLI, C# and .NET implementation.
CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.
This repo is used for servicing PR's for .NET Core 2.1 and 3.1. Please visit us at https://github.com/dotnet/runtime
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
The official repo for the design of the C# programming language
Quick Overview
The microsoft/referencesource repository contains the reference source code for the .NET Framework. It provides developers with a view into the inner workings of the framework, allowing them to better understand its implementation and behavior. This repository is not intended for direct use in projects but serves as a valuable resource for learning and debugging.
Pros
- Offers insight into the implementation details of the .NET Framework
- Helps developers understand and debug issues in their .NET applications
- Serves as a learning resource for advanced .NET programming techniques
- Provides transparency into Microsoft's development practices
Cons
- Not intended for direct use in projects
- May be overwhelming for beginners due to its complexity and size
- Updates may not always align with the latest .NET Framework releases
- Lacks comprehensive documentation for each component
Code Examples
As this is a reference source repository and not a code library, code examples are not applicable in this context. The repository contains the source code for the .NET Framework itself, which is not meant to be used directly in projects.
Getting Started
Since this is a reference source repository and not a code library, there are no specific getting started instructions. However, developers can explore the repository by:
- Visiting the GitHub repository: https://github.com/microsoft/referencesource
- Browsing through the various folders to find specific components of interest
- Using GitHub's search functionality to locate specific classes or methods
- Referring to the official .NET documentation for guidance on how to use the framework in your projects
Competitor Comparisons
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Pros of runtime
- More actively maintained and developed
- Open-source with community contributions
- Supports cross-platform development (.NET Core)
Cons of runtime
- Larger codebase, potentially more complex to navigate
- May have more frequent changes, requiring developers to stay updated
Code Comparison
referencesource:
public static int IndexOf(string source, string value, int startIndex, int count)
{
return IndexOf(source, value, startIndex, count, StringComparison.CurrentCulture);
}
runtime:
public static int IndexOf(string source, string value, int startIndex, int count, StringComparison comparisonType)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (value == null)
throw new ArgumentNullException(nameof(value));
return IndexOfCore(source, value, startIndex, count, comparisonType);
}
The runtime version includes additional null checks and uses a separate core method for implementation, potentially offering better error handling and modularity.
Mono open source ECMA CLI, C# and .NET implementation.
Pros of mono
- Open-source implementation of .NET Framework, allowing for greater community involvement and contributions
- Cross-platform support, enabling development for various operating systems beyond Windows
- More frequent updates and releases, potentially incorporating new features faster
Cons of mono
- May have compatibility issues with some Windows-specific .NET features
- Smaller ecosystem and community compared to the official Microsoft implementation
- Potentially less stable or optimized for certain use cases
Code Comparison
referencesource:
public static string Format(string format, object arg0)
{
return Format(null, format, new object[] { arg0 });
}
mono:
public static string Format(string format, object arg0)
{
return Format(format, new object[] { arg0 });
}
The code snippets show a minor difference in the implementation of the Format
method. The mono version omits the null
parameter present in the referencesource version, which likely represents a culture-specific formatting option.
CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.
Pros of coreclr
- Open-source and community-driven development
- Cross-platform support (Windows, macOS, Linux)
- Optimized for cloud and containerized environments
Cons of coreclr
- Smaller ecosystem compared to the full .NET Framework
- Some legacy APIs and features not supported
- Potential compatibility issues with older .NET applications
Code Comparison
referencesource:
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
coreclr:
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
The basic structure and syntax remain the same in both repositories. However, coreclr may include additional optimizations and cross-platform considerations in its implementation.
Summary
coreclr represents the open-source, cross-platform evolution of the .NET runtime, while referencesource provides the reference implementation for the full .NET Framework. coreclr offers better support for modern development practices and environments, but may lack some features present in the full framework. Both repositories maintain similar code structure and syntax for core functionality.
This repo is used for servicing PR's for .NET Core 2.1 and 3.1. Please visit us at https://github.com/dotnet/runtime
Pros of corefx
- Open-source and community-driven development
- Cross-platform support (Windows, macOS, Linux)
- More frequent updates and improvements
Cons of corefx
- Potentially less stable due to rapid development
- May lack some legacy Windows-specific features
- Learning curve for developers transitioning from referencesource
Code Comparison
referencesource:
public static string Format(string format, object arg0)
{
return Format(null, format, new object[] { arg0 });
}
corefx:
public static string Format(string format, object arg0)
{
return Format(null, format, arg0);
}
The corefx implementation is more concise, avoiding the creation of an unnecessary object array. This reflects the overall trend of performance optimizations in corefx.
Both repositories serve as valuable resources for .NET developers, with referencesource providing a stable reference for the .NET Framework, and corefx offering a more modern, cross-platform approach to .NET development. The choice between them depends on specific project requirements and target platforms.
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
Pros of Roslyn
- Open-source compiler with a more modern, extensible architecture
- Provides powerful APIs for code analysis and manipulation
- Supports newer C# language features and compilation targets
Cons of Roslyn
- Larger codebase, potentially more complex to navigate
- May have a steeper learning curve for contributors
- Some legacy .NET Framework components not included
Code Comparison
Roslyn (C# compiler implementation):
public override BoundNode VisitMethodDeclaration(MethodDeclarationSyntax node)
{
var symbol = (MethodSymbol)this.GetDeclaredSymbol(node);
return new BoundMethodDeclaration(node, symbol, null);
}
ReferenceSource (.NET Framework implementation):
public virtual MethodInfo GetMethod(String name)
{
return GetMethod(name, Type.DefaultLookup);
}
Summary
Roslyn represents a more modern, open-source approach to the C# compiler, offering extensive APIs for code analysis and manipulation. It supports newer language features but has a larger, potentially more complex codebase. ReferenceSource provides a view into the .NET Framework's implementation, which may be simpler in some areas but lacks the extensibility and openness of Roslyn.
The official repo for the design of the C# programming language
Pros of csharplang
- Focuses specifically on C# language design and proposals
- More active community involvement and discussions
- Provides detailed explanations of language features and their rationale
Cons of csharplang
- Limited to language specifications and proposals
- Doesn't include actual implementation code
- May be more challenging for beginners to understand and contribute
Code Comparison
csharplang (proposal example):
public static class StringExtensions
{
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? s) =>
string.IsNullOrEmpty(s);
}
referencesource (implementation example):
public static class String {
public static bool IsNullOrEmpty(String value) {
return (value == null || value.Length == 0);
}
}
The csharplang example shows a proposed extension method with nullable reference types, while the referencesource example displays the actual implementation of the IsNullOrEmpty
method in the .NET Framework.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
.NET Reference Source
The referencesource repository contains sources from Microsoft .NET Reference Source that represent a subset of the .NET Framework. This subset contains similar functionality to the class libraries that are being developed in .NET Core. We intend to consult the referencesource repository as we develop .NET Core. It is also for the community to leverage to enable more scenarios for .NET developers.
Please note that the referencesource repository is read-only. See this blog post for the rationale.
This repository does not accept feature requests or bug reports. To submit those, you need to go elsewhere:
License
The files in this repository are licensed under the MIT license unless otherwise specified in the file header. If the file header only contains a copyright header (e.g., "Copyright (c) Microsoft Corporation. All rights reserved.", you can assume the associated file to be MIT-licensed.
Top Related Projects
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Mono open source ECMA CLI, C# and .NET implementation.
CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.
This repo is used for servicing PR's for .NET Core 2.1 and 3.1. Please visit us at https://github.com/dotnet/runtime
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
The official repo for the design of the C# programming language
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot