# Google.Cloud.Diagnostics.Common - Class Project (5.3.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [5.3.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.Project)
- [5.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.2.0/Google.Cloud.Diagnostics.Common.Project)
- [5.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.1.0/Google.Cloud.Diagnostics.Common.Project)
- [5.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.0.0/Google.Cloud.Diagnostics.Common.Project)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.4.0/Google.Cloud.Diagnostics.Common.Project)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.3.1/Google.Cloud.Diagnostics.Common.Project)

    public static class Project

Reference documentation and code samples for the Google.Cloud.Diagnostics.Common class Project.

Operations for Cloud Console Projects.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> Project

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Diagnostics.Common](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common)

## Assembly

Google.Cloud.Diagnostics.Common.dll

## Methods

### GetAndCheckProjectId(string, MonitoredResource)

    public static string GetAndCheckProjectId(string projectId, MonitoredResource monitoredResource = null)

Determines the correct project id from a string project id and a [MonitoredResource](https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html).
If the specified project id is not null, it is returned. Otherwise, if the project id of
the MonitoredResource is not null, it is returned. It both are null,
an [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) is thrown.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `projectId` | `https://learn.microsoft.com/dotnet/api/system.string` The Google Cloud project ID. Can be null. |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, The monitored resource. If unset the monitored resource will be auto detected. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The Google Cloud project ID. |

### GetAndCheckServiceName(string, MonitoredResource)

    public static string GetAndCheckServiceName(string serviceName, MonitoredResource monitoredResource = null)

Determines the correct service name from a string `serviceName` and a [MonitoredResource](https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html).
If the specified service name is not null, it is returned. Otherwise, if the service name of
the MonitoredResource is not null, it is returned. It both are null,
an [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) is thrown.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` The service name. Can be null. |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, The monitored resource. If unset the monitored resource will be auto detected. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The service name that was passed in or detected. |

### GetAndCheckServiceVersion(string, MonitoredResource)

    public static string GetAndCheckServiceVersion(string serviceVersion, MonitoredResource monitoredResource = null)

Determines the correct service version from a string `serviceVersion` and a [MonitoredResource](https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html).
If the specified service version is not null, it is returned. Otherwise, if the service version of
the MonitoredResource provided or detected is not null, it is returned. It both are null,
an [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) is thrown.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceVersion` | `https://learn.microsoft.com/dotnet/api/system.string` The service version. Can be null. |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, The monitored resource. If unset the monitored resource will be auto detected. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The Google App Engine service version. |

### GetProjectId(string, MonitoredResource)

    public static string GetProjectId(string projectId, MonitoredResource monitoredResource = null)

Determines the correct project ID from a string `projectId` and a [MonitoredResource](https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html).
If the specified project ID is not null, it is returned. Otherwise, if the project ID of
the MonitoredResource is not null, it is returned. It both are null, null is returned.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `projectId` | `https://learn.microsoft.com/dotnet/api/system.string` The project ID. Can be null. |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, The monitored resource. If unset the monitored resource will be auto detected. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The Google Cloud project ID. |

### GetServiceName(string, MonitoredResource)

    public static string GetServiceName(string serviceName, MonitoredResource monitoredResource = null)

Determines the correct service name from a string `serviceName` and a [MonitoredResource](https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html).
If the specified service name is not null, it is returned. Otherwise, if the service name of
the MonitoredResource is not null, it is returned. It both are null, null is returned.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` The service name. Can be null. |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, The monitored resource. If unset the monitored resource will be auto detected. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The service name that was passed in or detected. |

### GetServiceVersion(string, MonitoredResource)

    public static string GetServiceVersion(string serviceVersion, MonitoredResource monitoredResource = null)

Determines the correct service version from a string `serviceVersion` and a [MonitoredResource](https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html).
If the specified service version is not null, it is returned. Otherwise, if the service version of
the MonitoredResource provided or detected is not null, it is returned. It both are null, null is resturned.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceVersion` | `https://learn.microsoft.com/dotnet/api/system.string` The service version. Can be null. |
| `monitoredResource` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MonitoredResource.html` Optional, The monitored resource. If unset the monitored resource will be auto detected. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | The service version that was passed in or detected. |