Visual C# Language
About the closest you can get are Nested Classes; but they're not two-way. For example:
using System;
public class Testing {
private int value;
private class Nest {
private Testing testing;
public Nest(Testing testing) {
this.testing = testing;
}
public void Method() {
testing.value = 1;
}
}
public int Value { get { return value; } }
}
public static void Main() {
Testing testing = new Testing();
testing.value = 1; // CS0122
}
This is kind of a pain for unit testing. Sometimes, we make methods public just for unit testing when they really should be private. We could put the unit tests in nested classes, internals or have the unit test classes inherit from the classes they are testing, but that wouldn't be as organized as the way we do it now.
I agree that the friend modifier can be bad design or even dangerous, but in the case of unit testing, I think it would be perfect.